Home > Net >  Entrust this kind of situation how to do?
Entrust this kind of situation how to do?

Time:04-10

Form2 Form1 as part of the interface, it has a TLP, containing 120 control code is generated dynamically,

The process is so of

Form2 X=new Form2 ();

CreateTLP generated 120 controls (X)//of TLP, then add Form2 on this step is for 2 seconds more

X.S howdialog ();//this step has more than 4 seconds,

I have try to put CreateTLP and Showdialog inside a function, and then do a delegate, an error to use the resources of this thread,

I want to, click enter Form2 interface, a loading Pop interface first came out, I have done, such as ShowDialog () is completed, shut off loading interface, show Form2 interface, how to implement?

CodePudding user response:

 public partial class Form1: Form 
{
Public _click ()
{
InitializeComponent ();
}

Private void Form1_Load (object sender, EventArgs e)
{

}

Private async void button1_Click (object sender, EventArgs e)
{
//open the form2 imitated loading animation
Form2 f2=new Form2 ();
F2. The Show ();
The BeginInvoke (act, f2);

}

//Task. Delay (5000) to imitate load time control
Public Func Act=async (x)=& gt; {
Await Task. Delay (5000);
X.C lose ();
return true;
};

}

CodePudding user response:

No, there are three interface, the first is the form1 main interface, the second is the TLP form2, the third is a loading GIF form3.

Form1 click open form2.

Because dynamic loading TLP + form2. Showdialog need 6 seconds,

So click open form2, jump out of the first form3 to loading, and then wait form2 jump out to, automatic turn off form3, then can operate form2,

CodePudding user response:

Can add events, managed to entrust in form1 loading is CreateTLP (X) is loaded, and then form2 can directly use,
Similar to this kind of the way,
https://blog.csdn.net/qq_38977566/article/details/114139986

CodePudding user response:

You might as well open load window click on the button, at the same time create form2 form2 create shut down after the completion of the load show form2

Always feel is the code you have any question, otherwise, how can you so long

CodePudding user response:

Async Task{
Form2 X=new Form2 ();

Await X.C reateTLP (X);


}

The
Var form2=await CreteForm2 ()
Form2. The show ()
  •  Tags:  
  • C#
  • Related