How to create a Do Not Respond console application?

For testing, the easiest way to make the program "Do not respond"? Break Windows messages or put them in an endless loop?

I tried a simple loop like

while(true) 

But that does not work. The test application is a C # console application. Does the fact that it works in the console make it "more responsive"? Perhaps there are some parts of the added console processing that make it respond all the time?

Update:

Changed this to a simple Winform application, which is placed in an endless loop. Worked to rejoice charm. Thanks Servy.

+4
source share
4 answers

The console application will never “Do Not Answer” from the perspective of Windows Task Manager. In fact, the task manager does not start your program, it launches the shell (cmd.exe) on which your program is running, and this shell is written so that it will always respond even if your program is missing. If you do not run your program through the shell, but run it directly, then there will be no user interface for the program, and it will not be an “application” in the task manager (this means that it will not be displayed in the “Application” tab), this it will be just a process.

If you just need to emulate any Do Not Respond program from the point of view of the task manager, you should make a simple winforms application and put it in an endless loop. If there is some obscure way to make the Do Not Responsive program from a console application, at least it will be much more complicated than with any of the standard types of desktop GUIs.

+6
source

You can do Thread.Sleep(X)

+3
source

The easiest way to make the program "without reacting" for an indefinite period is to use an infinite loop:

 while(true); 
+2
source

Do any work with the UI-ad (for the user interface application)

 Thread.Sleep While (true) 

this may give some idea of ​​what you are trying to execute ( .net console application stops responding when printing a large number of characters per line )

+1
source

Source: https://habr.com/ru/post/1435932/


All Articles