Winfrom multi-thread control form refresh sub-Form Control Main form dialog box space-time object, winfrom Form Control
1. This is because the sub-form is controlled by a thread. The Main form is affected when data is refreshed, because the primary and secondary forms exist in the form of Main man = new Main (); man. ShowDialog ();
2. solution:
Create a public class, assign a value to the Bool attribute, set an event for the method to refresh the data, and call refresh data after the current thread ends through the Timer control.
Code:
Public class policy
{
Public static bool IsImportSapFinished {get; set ;}
}
System. Windows. Forms. Timer timer = new System. Windows. Forms. Timer ();
Timer. Tick + = new EventHandler (this. Monitor );
Timer. Interval = 1000;
Timer. Enabled = true;
Timer. Start ();
Public void Monitor (object sender, EventArgs arg)
{
If (policy. IsImportSapFinished)
{
GetDate ();
Required Y. IsImportSapFinished = false;
}
}