zoukankan
html css js c++ java
项目需要刚写的Timer
Code
1
using
System;
2
using
System.Collections.Generic;
3
using
System.Text;
4
using
System.Timers;
5
6
7
namespace
Server
8
{
9
public
class
Stimer
10
{
11
private
int
times, _timers;
12
private
Timer t;
13
/**/
///
<summary>
14
///
Elapsed事件的频率 单位:秒
15
///
</summary>
16
public
int
Interval
17
{
18
set
{
this
.times
=
value; }
19
}
20
public
Stimer(
int
_t)
21
{
22
t
=
new
Timer(
1000
);
//
配置间隔时间为1000毫秒;
23
t.Elapsed
+=
new
ElapsedEventHandler(t_Elapsed);
24
t.AutoReset
=
true
; ;
//
配置是执行一次(false)还是一直执行(true);
25
t.Enabled
=
false
;
//
是否执行System.Timers.Timer.Elapsed事件;
26
this
.times
=
_t;
27
this
._timers
=
_t;
28
}
29
public
void
Start()
30
{
31
t.Start();
32
}
33
public
void
Stop()
34
{
35
t.Stop();
36
}
37
public
void
Restart()
38
{
39
t.Stop();
40
this
._timers
=
times;
41
t.Start();
42
}
43
public
void
Dispose()
44
{
45
t.Stop();
46
t.Dispose();
47
}
48
49
public
void
TimeOut()
50
{
51
Console.WriteLine(
"
aaaa
"
);
52
}
53
void
t_Elapsed(
object
sender, ElapsedEventArgs e)
54
{
55
if
(_timers
==
0
)
56
{
57
_timers
=
times;
58
TimeOut();
59
}
60
else
61
{
62
_timers
--
;
63
}
64
}
65
}
66
}
67
查看全文
相关阅读:
莫名其妙的float:left; 不能使元素紧贴父级的坑
将HTML元素转换成图片供用户下载(html2canvas + canvas2Image)
使用Git代替FTP进行虚拟主机的代码管理
jQuery: on()特别的几种用法
监控页面后退前进,浏览器文档加载事件之pageshow、pagehide
博客园Markdown编辑器试玩~~~
移动端调试神器(eruda)
移动端分享插件使用总结
sqlloader的使用------windows版
运维工作总结教训
原文地址:https://www.cnblogs.com/bobofsj11/p/1411628.html
最新文章
烧真机
mongodb指南
UnityEditor
C#
Redis指南
NoSQL指南
temp
《软件设计师》——UML
MPAndroid 的学习
C# List<string>之间的转换
热门文章
android 常用库的地址--dialog,recycler
JAVA中循环遍历list有三种方式
普通element ui table组件的使用
可拖拽dialog
C#获取汉字拼音和首字母
封装的PKPM BimView的方法
PKPM BIMViewer的使用
element ui改写实现两棵树
element-ui中select下拉框,选择后赋值成功,但是框上不显示的坑
vue component组件
Copyright © 2011-2022 走看看