当你调用 ShowAlarm 的时候,应该确保在UI主线程调用它。

解决方案 »

  1.   

                dlg.TopMost = true;
                dlg.Show();
    ->
                dlg.Show(this);
      

  2.   

    实测,不行,
    线程间操作无效: 从不是创建控件“MainForm”的线程访问它。这里是不是应该用委托?
      

  3.   

    dlg  是个什么东西?
      

  4.   


     private void button1_Click(object sender, EventArgs e)
            {
                Thread th = new Thread(ShowMessage);
                th.IsBackground = true;
                th.Start();
            }        //非UI线程的操作方法
            void ShowMessage()
            {
                if (this.InvokeRequired)
                {
                    Action<string> Show = (o) =>
                    {                    
                        //非UI线程操作UI控件时的方法写到这里
                        //...                };
                    this.Invoke(Show, string.Empty);
                }     
            }