秒表不会递增

时间:2009-08-23 09:41:05

标签: c# timer stopwatch

我不明白为什么这段代码在4小时后无法衡量。

    if (guildVaultRunStarter.IsRunning)
    {
        if (guildVaultRunTimer.ElapsedMilliseconds > 4 * 60 * 60 * 1000) // 4 hours
        {
            guildVaultRunStarter.Reset();
            log("Its been over 4 hours - empty bags.");
            return true;
        }
        else
        {
            log("guildVaultRunTimer.ElapsedMilliseconds = " +
                guildVaultRunTimer.ElapsedMilliseconds.ToString() + ".");
        }
    }
    else
    {
        log("Start the 4 hour guild vault countdown.");
        guildVaultRunStarter.Reset();
        guildVaultRunStarter.Start();
    }

日志记录显示:

[8/23/2009 12:17:21 PM]:Start the 4 hour guild vault countdown.
...
[8/23/2009 12:26:53 PM]:guildVaultRunTimer.ElapsedMilliseconds = 0.
...
[8/23/2009 12:27:26 PM]:guildVaultRunTimer.ElapsedMilliseconds = 0.

为什么总是0?

2 个答案:

答案 0 :(得分:4)

这只是guildVaultRunTimerguildVaultRunStarter之间的拼写错误吗?

if (guildVaultRunStarter.ElapsedMilliseconds > ...

毕竟,你似乎永远不会开始guildVaultRunTimer

答案 1 :(得分:0)

你在哪里实例化定时器以及这段代码在哪里/如何调用?