C# terminate thread with stop variable
来源:互联网 发布:淘宝头条问答 编辑:程序博客网 时间:2024/06/08 08:19
namespace FrameworkTest
{
public partial class Form1 : Form
{
private bool stopThread = false;
delegate void InsertListCallback(int index, object item);
private void btnStart_Click(object sender, EventArgs e)
{
stopThread = false;
Thread t = new Thread(ThreadProc);
t.IsBackground = true;
t.Start();
}
private void ThreadProc()
{
int i = 0;
while (!stopThread)
{
this.Invoke(new InsertListCallback(
listBox1.Items.Insert),
new object[] { 0, i.ToString() });
Thread.Sleep(20);
i++;
}
if (stopThread)
this.Invoke(new InsertListCallback(
listBox1.Items.Insert),
new object[] { 0, "thread was stoped" });
}
private void btnStop_Click(object sender, EventArgs e)
{
stopThread = true;
}
}
}
- C# terminate thread with stop variable
- Thread.stop()
- twisted thread reactor.stop
- java stop thread
- thread and share variable
- terminate
- 《C++ Concurrency in Action》笔记15 a thread-safe queue with condition variable
- How to Stop a Thread
- Thread中的stop方法过时
- 略坑的Thread.stop()
- 为什么Thread.stop()方法被弃用
- java如何正确停止Thread,thread.stop ?
- Use event to terminate a windows thread gracefully (MSDN sample)
- Two ways to terminate blocking socket thread gracefully
- stop subthread example with Event
- An instance of “(null)” is already running. Choose “Stop” to terminate and launch a new instance.
- Java Thread Stop方法以及替换实现
- 转:为什么不鼓励使用 Thread.stop?
- 五种提高 SQL 性能的方法
- vs2005 连接ACCESS代码
- MSSQL字符串函数2
- 检查输入的字符串是否为回文 当一个字符串顺读倒读时都一样,则这样的字符串就是回文了 例如 123321就是
- SAP BC417 课程中文自学笔记
- C# terminate thread with stop variable
- 使用.NET Framework 2.0 新功能抓屏
- Javascript 判断radio是否选中及RegExp正则表达式
- 如何让管理软件提升企业战略执行力
- 使用键盘移动鼠标指针
- fflush
- WinSock WSAEventSelect 服务端模型 (单线程)
- 如何动态加载控件以及插件编程思想
- 动态规划算法剖析