c#计时器的计算编译问题
我有一个带标签的windows窗体和一个名为c#计时器的计算编译问题,c#,.net,visual-studio-2010,timer,system.net,C#,.net,Visual Studio 2010,Timer,System.net,我有一个带标签的windows窗体和一个名为aTimer的system.net计时器 计时器是在如下外部类中创建的: // Create a timer with a 3 minute interval. common.aTimer = new System.Timers.Timer(3000); // Hook up the Elapsed event for the timer. common.aTimer.Elapsed += new ElapsedEventHandler(OnTime
aTimer
的system.net计时器
计时器是在如下外部类中创建的:
// Create a timer with a 3 minute interval.
common.aTimer = new System.Timers.Timer(3000);
// Hook up the Elapsed event for the timer.
common.aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
// Set the Interval to 3 minutes (180000 milliseconds).
common.aTimer.Interval = 180000; // 3000; //
common.aTimer.Enabled = true;
mTimerRunning = true;
在我的表单中,我运行codeOnTimedEvent
启动后台工作程序
我想在标签上显示下一步操作前的秒数
我尝试过这个,但无法编译:
lblStatus.BeginInvoke(new Action(() =>
{
lblStatus.Text = "timer running - Check inbox in " & common.aTimer.Interval - common.aTimer.Elapsed & " seconds!";
}));
我有一个编译错误事件'System.Timers.Timer.appeased'只能出现在+=或-=
那么正确的方法是什么呢
理想情况下,我会更新标签,以显示nxt运行的时间。我猜您来自VB背景 以下不是有效的c#代码
不用于c#中的字符串连接,请使用&
运算符李>+
是双精度,aTimer.Interval
是一个事件。你不能添加它。这根本没有道理李>aTimer.appead
lblStatus.Text = "timer running - Check inbox in " & common.aTimer.Interval - common.aTimer.Elapsed & " seconds!";