1.
Methods of using Event delegates
Objects: Main form: frmmain load form: frmloading
Ideas:
Show Form frmloading before the main form loads, when the main form is finished loading (the first time it is displayed), close frmloading
The C # code looks like this
Using System;
Using System.Collections.Generic;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Linq;
Using System.Text;
Using System.Windows.Forms;
Using System.Threading;
Namespace CDemoTest
{
public partial class Frmmain:form
{
Private frmloading Loadform;
Public Frmmain ()
{
Create the Load form loadform = new frmloading ();
Specify an event when the form is finished loading
This. shown + = Frmloading_close;
Loadform.show ();
Main form Initialization method
InitializeComponent ();
}
Declaring closed load form methods
private void Frmloading_close (object sender, EventArgs e)
{
Loadform.close ();
}
private void Frmmain_load (object sender, EventArgs e)
{
Thread.Sleep (3000);
}
}
}
2.
1. In the main method, display the splash screen first, and note the use of show instead of ShowDialog.
2. Then in the normal way, Application.Run (MainForm);
3. In the MainForm constructor, start the load thread.
A flag is set in 4.mainForm, and the flag is set to a value if the load is complete.
5. As the start screen using the form, note the detection mainform in the flag, if the main form loading is complete, it closes itself.
The feeling method is better, record a bit.
Several practices for loading interfaces in C #