For testing, what is the easiest way to make a program appear “Not Responding”? Interrupt Windows messages or put it in an infinite loop?
I have tried a simple loop like
while(true)
But that does not work.
The test application is a C# console app. Does the fact that it’s running in a console make it “more responsive”? Perhaps there are some parts of the added console handling that make it respond all the time?
Update:
Changed it to a simple Winform Application put that into an infinite loop. Worked lika a charm. Thanks to Servy.
A console application will never be “Not Responding” from the point of view of Windows Task Manager. In reality task manager isn’t running your program, it’s running a shell (cmd.exe) that is running your program, and that shell is written such that it will always be responding even if your program isn’t. If you aren’t running your program through a shell but are starting it directly, then there won’t be any UI for the program and it won’t be an “Application” in task manager (meaning it won’t show up in the “Application” tab), it will just be a process.
If you just need to mimic any program “Not Responding” from the point of view of task manager you should make a simple winforms application and put that in an infinite loop. If there is some obscure way of making a program appear “Not Responding” from a console app, at the very least it will be much harder than from any of the standard desktop GUI types.