首页  编辑  

线程中控制UI控件

Tags: /C#/进程、线程处理/   Date Created:

using System . Threading;

public void DoWork()

{

    Thread . Sleep( 5000 );

   Invoke( new EventHandler (DoInvoke));

}

private void DoInvoke( object sender , EventArgs e)

{

   button1 . Enabled = true ;

}

private void button1_Click( object sender , EventArgs e)

{

   button1 . Enabled = false ;

    Thread vThread = new Thread ( new ThreadStart (DoWork));

   vThread . Start();

}