views:

92

answers:

1

In .NET WinForms I want to display message in a status bar and suspend the program execution until user moves mouse or presses keyboard. How can I do that?

A: 

Put your program into a separate thread, suspend the thread with

System.Threading.Thread.CurrentThread.Suspend()

and restart it from another thread, which is listening to the mouse/keyboard-events.

Edit:

Ok. Thread suspension is evil and not necessary here, as the Program-Thread itself enters a Suspended - better a Sleeping or Waiting state. So just wait (sleep-cycle, WaitHandle - some semaphore, whatever) for the Interface-Thread to allow the Program-Thread to progress.

Leonidas
Suspend is obsolete. http://msdn.microsoft.com/en-us/library/system.threading.thread.suspend.aspx
Brian Rasmussen