如果是顺序执行的话,那就初始时,将第一个timer的enable=true,其他为false
第一个中写timer1.enable=false;
....
timer2.enable=true;//开启第二个
第一个中写timer1.enable=false;
....
timer2.enable=true;//开启第二个
解决方案 »
- 正则分割字符串的问题
- winform程序在别人电脑上登陆提示错误,但仍能运行
- 请问,我用c#winform开发了一个系统,运行几天后打印出票变慢,什么原因?
- 关于form刷新问题
- 谁知道ConfigManager.dll的具体用法?
- 输入的值为0~9999 或者为空,正则表达式如何写?
- 一个C++BUILDER程序员学习C#(VS.NET2005)的郁闷!
- 关于C# WINFORM 两个Flash控件
- 可以让gridview做到 显示10条记录,分5行,每行显示2条?
- 将datagridview控件导出为Excel时为什么出现错误
- 老是提示select附近有语法错误,我没检查出来,帮我看看吧?谢谢!
- 如何去除网页源码中的html??
贴代码 System.Timers.Timer t = new System.Timers.Timer(3000);
t.Elapsed += new System.Timers.ElapsedEventHandler(theout);
t.AutoReset = true;
t.Enabled = true; public void theout(object source, System.Timers.ElapsedEventArgs e)
{
//执行压缩
string strFilePaht = @"D:\Back\131121082103.txt";
string strFileName = System.IO.Path.GetFileName(strFilePaht);
string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(strFilePaht);
GetFileToZip(strFilePaht, strFileName, @"d:\\Back\\" + fileNameWithoutExtension + ".zip"); }比如theout执行压缩需要10秒。但是Timer只给了3秒。怎么操作让theout执行完成之后,才进行下一次操作。
void theout(object source, System.Timers.ElapsedEventArgs e)
{
if (Interlocked.CompareExchange(ref inProcessing, 1, 0) == 0)
{
try
{
// your code here...
}
finally
{
inProcessing = 0;
}
}
}