C#定时检查子线程是否执行完成(定时器检查)
来源:互联网 发布:51单片机课程设计课题 编辑:程序博客网 时间:2024/06/05 20:44
定时器定时去检验子线程是否执行完成。如果完成关闭定时器,继续执行别的方法。
private volatile static FileReadManager uniqueInstance; private Timer _FileReadTimer = null; private Timer _PriorityFileReadTimer = null; //定时器开始调用的方法 public void Start() { try { _FileReadTimer = new System.Timers.Timer(); //多长时间去检查一次(1000毫秒=1秒) _FileReadTimer.Interval = 10000; _FileReadTimer.Elapsed += new ElapsedEventHandler(FileRead); _FileReadTimer.Start(); } catch (Exception ex) { LogHelper.WriteError(ex, "启动文件读取定时器"); } } public void Stop() { try { if (_FileReadTimer != null) { _FileReadTimer.Stop(); _FileReadTimer.Close(); } } catch (Exception ex) { LogHelper.WriteError(ex, "停止文件读取定时器"); } } private void FileRead(object obj, ElapsedEventArgs e) { try { _FileReadTimer.Stop(); _FileReadTimer.Close(); //需要检查多个单线程是否执行完成的方法 //子线程1 //子线程2 //子线程3 } catch (Exception ex) { LogHelper.WriteError(ex, "文件读取定时器方法"); } finally { _FileReadTimer.Start(); } }
0 0
- C#定时检查子线程是否执行完成(定时器检查)
- C#定时检测子线程是否已经完成
- linux 检查定时检查程序是否运行
- 检查线程是否关闭
- C# 检查是否联网
- C#检查是否联网
- C#检查网络是否连通
- C#检查计算机是否联网
- 检查数据库是否存在锁和检查实时执行计划
- 子线程中执行定时器
- 检查软件开发过程执行是否成功?
- shell awk 检查程序是否执行
- C#笔记(16)检查本机是否联网
- 检查线程是否安全的小工具
- 检查邮箱是否有新邮件+线程池
- C#检查输入的是否是数字
- C#检查网络是否连接的方法
- C# 检查文件夹和文件是否存在
- ImageView 设置图片
- Install and config Redis on Mac OS X via Homebrew
- 关于Android4.x系统默认显示方向各种修改
- myeclipse编写的html页面乱码问题
- listview数据显示在最底部的设置
- C#定时检查子线程是否执行完成(定时器检查)
- spark算子cogroup讲解
- Linux信号详解
- 404. Sum of Left Leaves
- 测试要求和指标
- TensorFlow入门-MNIST & softmax regression
- 数据库事务隔离级别
- Datatables v1.10服务端模式启动js-java版本
- 完美解决频繁跳槽者的两大求职难题