多线程操作窗体控件
2008-08-01 09:05
316 查看
delegate void SetTextCallback(string text);<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
private void SetText(string text)
{
// InvokeRequired required compares the thread ID of the
// calling thread to the thread ID of the creating thread.
// If these threads are different, it returns true.
if (this.textBox1.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] { text });
}
else
{
this.textBox1.Text = text;
}
}
SetText(time.ToString());
private void SetText(string text)
{
// InvokeRequired required compares the thread ID of the
// calling thread to the thread ID of the creating thread.
// If these threads are different, it returns true.
if (this.textBox1.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] { text });
}
else
{
this.textBox1.Text = text;
}
}
SetText(time.ToString());
相关文章推荐
- 多线程中 用委托 操作 窗体的控件
- 多线程操作窗体控件
- [转]c#有关winform的两个代码片段(多线程操作窗体控件与窗体淡入淡出效果)
- 多线程操作之窗体控件
- 多线程操作之窗体控件
- 窗体控件的多线程操作
- 多线程操作窗体控件
- c#有关winform的两个代码片段(多线程操作窗体控件与窗体淡入淡出效果)
- [转] c#有关winform的两个代码片段(多线程操作窗体控件与窗体淡入淡出效果)
- Winform跨窗体操作控件(使用委托)
- 关于如何操作其他窗体的控件或变量的方法!
- c# 多线程 操作控件 使用代理
- 多线程操作控件属性
- Winform控件多线程操作控件的解决方案
- vs2005的form的委托 实现多线程操作richedit控件显示消息
- c# winform下使用多线程时在线程里如何安全访问窗体控件InvokeRequired
- 如何在子线程中操作窗体上的控件
- 在一个线程中操作窗体线程的控件
- C# 委托实例(跨窗体操作控件)
- MFC线程内操作主窗体 控件