Home > Net >  Application. The Run (form) form code does not continue after shut down
Application. The Run (form) form code does not continue after shut down

Time:11-17

 
FormBrowser form=new FormBrowser ();
SVC. FormBrowser=form;
Application. The Run (form);
Console. WriteLine (" 123 ");

Code as above, I manually close FormBrowser window, is the point in the top right corner of the cross closed form, the Console. WriteLine (" 123 ") to perform
But if in this form. The close (), the program will not perform the Console. WriteLine (" 123 "); Just stuck. Why is the following code will not perform?

CodePudding user response:

Instances have been destroyed, how to open again? You need to instantiate again to, you should application. The run (form) into the form. ShowDialog ();

CodePudding user response:

Application. The Run () this is the Main program winform standard (the Main Main thread) block statements, Windows across the window system messages are sent to the block with the system of the Main window, the word "law" is blocked,

CodePudding user response:

For winform main window. This is completely by the Close, unless you write the code for any other additional operations, but assuming start is not a Console application, so can't find the Console, process would crash at run time,

If you create the console application (note that is not a Windows program), the main program code should be like this:
 var f=new _click (); 
F.S how ();
Console. WriteLine (" system into Pending state... ");
Task. The Run (async ()=& gt;
{
While (true)
{
Await Task. Delay (10000);
}
}), Wait ();


Makes the console of the main program block, and allow Windows window to receive messages,

Or do you create a console process (note that is still the process of the console, you use the Application. The Run (... ) here to load an "invisible window, the window control on the Windows status bar icon just area (the place is QQ icon) to create a" right "control menu, such Windows window can receive messages, and you in the window to the Console output can code in a separate Console window shows, so the output of the practical significance, as the # 1 floor say otherwise, you wrote a general people not to use the logic design,

CodePudding user response:

Help!!!!!!!!!!!!!!!!!!!
  •  Tags:  
  • C#
  • Related