开发者

.NET WinForms: suspend code until mouse move or keyboard press

In .NET WinForms I want to display message in a s开发者_StackOverflow中文版tatus bar and suspend the program execution until user moves mouse or presses keyboard. How can I do that?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜