C#跨线程窗口调用

public void ShowChatRoom()
        {
            ChatRoom room = CreateChatRoom();

            if (room.InvokeRequired)
            {
                EmptyMethod m = new EmptyMethod(room.Show);
                this.Invoke(m);                

                EmptyMethod m2 = new EmptyMethod(room.BringToFront);
                this.Invoke(m2);
            }
            else
            {
                room.Show();
                room.WindowState = System.Windows.Forms.FormWindowState.Normal;
                room.BringToFront();
            }           
        } 

你可能感兴趣的:(C#)