Reputation: 49247
I have an application that interacts with another application using SendMessage (among other things). Everything works fine until the other application hangs (either because it has actually frozen or it is doing a long, blocking call). I would like to simulate an application hanging using a C# WinForms application. Is there any way to start a long running, blocking call? Or maybe a way to cause the application to actually freeze? Maybe something like WebClient.DownloadString(), but something that will never return.
Upvotes: 2
Views: 2829
Reputation: 33738
How about you just turn the message pump off? Then not only will your app appear to be frozen.. the system will actually report it as frozen (a la IsHungAppWindow(hWnd)).
Upvotes: 0
Reputation: 59645
If you want to simulate a long running task, use
Thread.Sleep(timeout);
and with Timeout.Infinite
if you want to block forever.
If you want to simulate heavy processor usage, too, use an infinite loop.
while (true) { }
Upvotes: 0
Reputation: 421988
while(true) { } // busy waiting
Thread.Sleep(time); // blocking
Upvotes: 5