CodePudding user response:
If there is nothing wrong with program, the interface design is reasonable, the only consider a better performance (memory, memory is big) machines,CodePudding user response:
Too many controls, if required must be loaded at a time, had better give a progress bar or message;If there is no mandatory requirements, in accordance with the feature points in a class,
In the left navigation tree, put the different controls to different Tab,
CodePudding user response:
Has nothing to do with the UI processing should be separate, asynchronous execution, and then when the main thread is performed before call to update the interface, such as testing the following example:using System;
Using System. The Threading;
using System.Windows.Forms;
The namespace WindowsFormsApp1
{
Public partial class Form1: Form
{
Public _click ()
{
InitializeComponent();
}
Void the button1_Click (object sender, EventArgs e)
{
For the Text="beginning of the test";
The Test ();
}
Void Test ()
{
Thread.sleep (10000);
This. For. Text="test";
}
}
}
When you click on the button, you will find that the interface card died within 10 seconds, the window way root can't use the mouse to drag! This procedure is very bad, and change to the
using System;you will find in the execution of a time-consuming process can also drag the window freely,
Using System. The Threading;
Using System. The Threading. The Tasks;
using System.Windows.Forms;
The namespace WindowsFormsApp1
{
Public partial class Form1: Form
{
Public _click ()
{
InitializeComponent();
}
Async void button1_Click (object sender, EventArgs e)
{
For the Text="beginning of the test";
Await the Test ();
This. For. Text="test";
}
Task Test ()
{
The return of Task. The Run (()=& gt;//has nothing to do with the UI refresh statement in this anonymous delegate to execute
{
Thread.sleep (10000);
});
}
}
}
Suppose to be modified in the process of asynchronous concurrent window control, then you need to use the entrusted to access controls, for example:
using System;
Using System. The Threading;
Using System. The Threading. The Tasks;
using System.Windows.Forms;
The namespace WindowsFormsApp1
{
Public partial class Form1: Form
{
Public _click ()
{
InitializeComponent();
}
Async void button1_Click (object sender, EventArgs e)
{
For the Text="beginning of the test";
Await the Test ();
This. For. Text="test";
}
Task Test ()
{
The return of Task. The Run (()=& gt;//has nothing to do with the UI refresh statement in this anonymous delegate to execute
{
Thread.sleep (2500);
This. For the BeginInvoke (delegate (Action)
{
This. For. Text="1";
});
Thread.sleep (2500);
This. For the BeginInvoke (delegate (Action)
{
This. For. Text="2";
});
Thread.sleep (2500);
This. For the BeginInvoke (delegate (Action)
{
This. For. Text="3";
});
Thread.sleep (2500);
});
}
}
}
Here, in the execution of a time consuming process of asynchronous visited UI interface controls, you need to use the BeginInvoke entrusted to operate the control, use the BeginInvoke. Entrusted to Invoke operation control, which is 15 years ago in the net of some operation specification,
CodePudding user response:
Simple summarize, is, in fact, most of the time you use has nothing to do with the UI interface operation give somebody else's UI thread to "card dead, blocked, causing interface look dead, actually interface can be very sensitive, can at any time to refresh, can quickly respond to various events, not application form can not, is the designer's knowledge, is to blame,CodePudding user response:
Upstairs irrelevant answer, the somebody else is controls more display card, pay attention to the topic,CodePudding user response:
Sp1234 has answered,Key is to read data, UI binding these operations, asynchronous,
If some SQL need of optimization and so on, did not elaborate,
Outline is the main thread and asynchronous separation,
CodePudding user response: