码迷,mamicode.com
首页 > 编程语言 > 详细

线程暂停。

时间:2014-11-29 10:21:01      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:io   ar   sp   for   on   art   bs   ad   as   

using System; using System.Text;

using System.Windows.Forms;

using System.Threading;

namespace WindowsApplication1

{  

   public partial class Form1 : Form

    {     

     public Form1()        

     {            

     InitializeComponent();     

    }

        private void button1_Click(object sender, EventArgs e)    

     {          

   Thread th = new Thread(YourThread);       

      th.Start();        

}

        private void textBox1_TextChanged(object sender, EventArgs e)   

      {      

       if (textBox1.Text.Length >= 4)       

      {         

        detailCollectedEvent.Set();                

      // 当textBox1的文本超过4位,发一个通知     

        }       

  }

        AutoResetEvent detailCollectedEvent = new AutoResetEvent(false);    

     void YourThread()  

       {           

  MessageBox.Show("input you bank account details into the textbox");           

  detailCollectedEvent.WaitOne();                  

    // 等候通知           

  MessageBox.Show("we will keep the secret.");

        }  

   }

}

线程暂停。

标签:io   ar   sp   for   on   art   bs   ad   as   

原文地址:http://www.cnblogs.com/ChengDavid/p/4130152.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!