winform服务,线程问题 winform服务中,用timer隔一段时间循环执行方法,到某个时间点让线程休息sleep,后在执行 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 protected override void OnStart(string[] args) { //int number = Convert.ToInt32(DateTime.Now.Hour.ToString()); //string timeNow = DateTime.Now.ToShortTimeString(); //if (timeNow.Equals("10:36")) //{ // //Thread.Sleep(1000 * 60 * (60 * 8 - 1));//线程休眠到第二天 // Thread.Sleep(1000 * 60 * 2); //} //else //{ //2.5个小时自动更新一次 System.Timers.Timer t = new System.Timers.Timer(); t.Interval = 1000 * 60 * 60 * 2.5; //t.Interval = 1000 * 60; t.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Click); //Timer_Click是到达时间的时候执行事件的函数 t.AutoReset = true; //设置是执行一次(false)还是一直执行(true) t.Enabled = true; //是否执行System.Timers.Timer.Elapsed事件 t.Start(); //} }循环执行,到晚上10点线程停止,到第二天早上6点线程开启 飞信官方API WinForm 自定义控件TextBox问题 XML 反序列化的时候如何识别是哪个对象?????? 关于xml输出的问题 疑惑(绑定)? 急求水晶报表在连续纸张上打印的问题 安装msde时失败 在下菜鸟请教一个小问题,C#的命名空间的要求 C# winform 重写窗体? 我想在dataGrid中某一列可以输入,其他的列只读,怎么办? 多页面登陆注销 c# import twain_32.dll问题
{
//int number = Convert.ToInt32(DateTime.Now.Hour.ToString());
//string timeNow = DateTime.Now.ToShortTimeString();
//if (timeNow.Equals("10:36"))
//{
// //Thread.Sleep(1000 * 60 * (60 * 8 - 1));//线程休眠到第二天
// Thread.Sleep(1000 * 60 * 2);
//}
//else
//{
//2.5个小时自动更新一次
System.Timers.Timer t = new System.Timers.Timer();
t.Interval = 1000 * 60 * 60 * 2.5;
//t.Interval = 1000 * 60;
t.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Click); //Timer_Click是到达时间的时候执行事件的函数
t.AutoReset = true; //设置是执行一次(false)还是一直执行(true)
t.Enabled = true; //是否执行System.Timers.Timer.Elapsed事件
t.Start();
//}
}循环执行,到晚上10点线程停止,到第二天早上6点线程开启