C# 自定义等待窗口
private SynchronizationContext syncContext = null; public WaitWindow() { InitializeComponent(); syncContext = SynchronizationContext.Current; } private void DisplayProgress() { while (true) { syncContext.Post(delegate (object target) { Label lProgress = (Label)target; if (lProgress.Left + lProgress.Width >= Width) { lProgress.Left = 0; } else { lProgress.Left += 10; } }, lblProgress); Thread.Sleep(100); } } //waitWnd = new WaitWindow(); //waitWnd.Owner = this; //waitWnd.Show(); //if (waitWnd != null) //{ // waitWnd.Close(); //} private void WaitWindow_Load(object sender, EventArgs e) { Thread runProgressThread = new Thread(new ThreadStart(DisplayProgress)); runProgressThread.IsBackground = true; runProgressThread.Start(); }