Several practices for loading interfaces in C #

Source: Internet
Author: User

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 #

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.