This question has already been answered:
- Stop work flow by pressing the answer button 3
There is a class for inverting mouse movement. When calling the Stop method, the program continues to run. When you use Abort prog closes. How to stop the loop in the MouseLoop method?
class Inverter { private Point currentPosition; private bool exit; public void Start() { currentPosition = Cursor.Position; exit = false; (new Thread(new ThreadStart(MouseLoop))).Start(); } public void Stop() {exit = true;} private void MouseLoop() { Thread.CurrentThread.IsBackground = true; Thread.CurrentThread.Priority = ThreadPriority.Highest; while (!exit) { Point newPosition = Cursor.Position; int right = currentPosition.X - (newPosition.X - currentPosition.X); int maxWidth = SystemInformation.VirtualScreen.Width; if (right >= maxWidth) { right -= 3; } else if (right <= 0) { right += 1; } int bottom = currentPosition.Y - (newPosition.Y - currentPosition.Y); int maxHeight = SystemInformation.VirtualScreen.Height; if (bottom >= maxHeight) { bottom -= 3; } else if (bottom <= 0) { bottom += 1; } Cursor.Position = new Point(right, bottom); currentPosition = Cursor.Position; Thread.Sleep(1); }}}}
abortif your thread does not have a variable? Can you show the code with theabortmethod? - Vitaliy ShebanitsAbortcode? - VladD 4:04 pm