Home > Net >  Turn thread open the modal form
Turn thread open the modal form

Time:03-29

modal window as shown in figure animation is not open to switch to main form...




The code is as follows:
//system loading animation
Private void SystemLoadCartoon ()
{
Thread LoadCartoon=new Thread (the delegate ()
{
String name="initializing, please later... ";
CartoonForm cartoonForm=new cartoonForm (name);
//don't show the Form of action buttons, prevent in advance to close the window to the back of the invok method error
CartoonForm. ControlBox=false;
//display window
CartoonForm. StartPosition=FormStartPosition. CenterScreen;
CartoonForm. ShowInTaskbar=false;//is not in the task bar shows
//cartoonForm. The TopMost=true;
CartoonForm. ShowDialog ();
});

LoadCartoon. Start ();
}

CodePudding user response:

Originally the mask layer should not use another form,
The cartoonForm window is a single thread, can only blocked threads, it is in
If you really like in this way, change the way of thinking (window only in the main thread of instances and operation) time-consuming operations on the thread,
For example:
 public void ShowLoad (Action fun) 
{
CartoonForm cartoonForm=new cartoonForm ();
New Thread (p=& gt;
{
Fun. The Invoke ();
//close the load window
CartoonForm. Invoke (new Action (()=& gt; {
CartoonForm. Close ();
}));
}). The Start ();
CartoonForm. ShowDialog ();
}

The
ShowLoad (()=& gt; {
//I'm loading data manipulation
System. Threading. Thread. Sleep (5000);
});

CodePudding user response:

Because you opened a thread to start, there is no parent form what happened, why want to do it, is to display a wait interface?

CodePudding user response:

Yes want to display a wait can interface with main form according to minimize...
  •  Tags:  
  • C#
  • Related