読み込みに時間がかかる複数のコントロールを持つフォーム (コード内のcomplexForm ) があります。そこで、初期ロード時間を短縮するために別のスレッドを作成することにしました。待機フォームのラベル コントロール (コードのForm1 ) が最初に表示されないことを除いて、すべて正常に動作します。Form1 がオフになるほんの一瞬前。私の質問は、ラベル コントロールが表示されないのはなぜですか?
[STAThread]
static void Main()
{
Thread thread = new Thread(delegate()
{
var wait = new Form1(); //simple form with a label control with text "please wait"
wait.Show();
var complexUI = new complexForm();// this takes long time to load
wait.Dispose();// it will go off even without this method
// MessageBox.Show("loaded");
});
thread.SetApartmentState(ApartmentState.STA);
thread.Priority = ThreadPriority.Highest;
thread.IsBackground = true;
thread.Start();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new main());
}