Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a console application appear "Not Responding"?

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.

like image 219
inquam Avatar asked Sep 24 '12 13:09

inquam


People also ask

How do you make an app not responding?

Force stop the app The easiest way to fix an app that keeps crashing on your Android smartphone is to simply force stop it and open it again. To do this, go to Settings -> Apps and select the app that keeps crashing. Tap on the app's name and then tap on 'Force stop'.

Can a program come back from not responding?

If the program stopped responding recently, you can try restoring Windows to a previous date when the problem was not occurring. The restore process can get the program back to a working state and may even fix other issues you are experiencing on your computer.

What does Application Not Responding mean?

ANR (App Not Responding) is a state in which the app is frozen and does not respond to any user gestures or draw. Unlike unresponsive gestures which are attributed to a design decision (e.g. an image that mistakenly looks like a tappable button), ANRs usually occur due to long running code that freezes the “UI thread”.

How do I run a console application?

Run the appPress Ctrl + F5 to run the program without debugging. A console window opens with the text "Hello World!" printed on the screen. Press any key to close the console window.


3 Answers

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.

like image 184
Servy Avatar answered Nov 10 '22 10:11

Servy


You could do a Thread.Sleep(X)

like image 28
Erix Avatar answered Nov 10 '22 10:11

Erix


The easiest way to make a program 'not responding' indefinitely is to use an infinite loop:

while(true);
like image 38
Devin Burke Avatar answered Nov 10 '22 08:11

Devin Burke