110,532
社区成员
发帖
与我相关
我的任务
分享
public class ThreadTest
{
private string _text;
private System.Threading.Thread _thread;
public event EventHandler UpdateControl;
public string Text
{
get { return _text; }
set { _text = value; }
}
public ThreadTest() { }
public void Start()
{
_thread = new System.Threading.Thread(
new System.Threading.ThreadStart(delegate()
{
if (UpdateControl != null)
{
UpdateControl(this, EventArgs.Empty);
}
}));
_thread.Start();
}
}
public class ThreadTest
{
private string _text;
private Control _owner;
private System.Threading.Thread _thread;
public string Text
{
get { return _text; }
set { _text = value; }
}
public Control Owner
{
get { return _owner; }
set { _owner = value; }
}
public ThreadTest() { }
public ThreadTest(Control owner)
{
_owner = owner;
}
public void Start()
{
_thread = new System.Threading.Thread(
new System.Threading.ThreadStart(delegate()
{
_owner.Invoke(new MethodInvoker(delegate()
{
_owner.Text = _text;
}));
}));
_thread.Start();
}
}