C#在线程中调用控件的方法
C#在线程中调用控件的方法
public delegate void CallSetLogin();
private void btnOK_Click(object sender, EventArgs e)
{
Thread pThread = new Thread(new ThreadStart(Login));
pThread.Start();
}
private void Login()
{
SetLogin();
}
private void SetLogin()
{
try
{
if (this.InvokeRequired)
{
CallSetLogin pCallSetLogin = new CallSetLogin(SetLogin);
this.Invoke(pCallSetLogin);
}
else
{
txtUserName.Text = "1191120815";
}
}
catch { }
}
posted on 2010-06-12 15:16 kisstome88 阅读(596) 评论(0) 收藏 举报
 
                    
                     
                    
                 
                    
                 
 
         
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号