C# 线程中显示一个新窗体

来源:互联网 发布:festo液压仿真软件 编辑:程序博客网 时间:2024/05/16 09:24

原文地址:http://blog.csdn.net/surgent/article/details/5937978

代码:

[c-sharp] view plaincopy
  1. private void ThreadFunc()  
  2. {  
  3.     MethodInvoker mi = new MethodInvoker(this.ShowMsgForm);  
  4.     this.BeginInvoke(mi);  
  5. }  
  6. private void ShowMsgForm()  
  7. {  
  8.     MsgForm msg = new MsgForm();  
  9.     msg.Show();  
  10. }  
  11. private void button1_Click(object sender, System.EventArgs e)  
  12. {  
  13.     FormThread = new Thread(new ThreadStart(ThreadFunc));  
  14.     FormThread.Start();  
  15. }  
 

原创粉丝点击