C# 使用秒表时,它不会';我不能正常工作

C# 使用秒表时,它不会';我不能正常工作,c#,stopwatch,discord,C#,Stopwatch,Discord,我正在使用discord bot,我正在尝试检查时间服务的时间,但它只显示一次时间,然后写入0 public async Task HandleCommand(SocketMessage messageParam) { // Don't process the command if it was a System Message var message = messageParam as SocketUserMessage; if (message == null ||

我正在使用discord bot,我正在尝试检查时间服务的时间,但它只显示一次时间,然后写入0

public async Task HandleCommand(SocketMessage messageParam)
{
    // Don't process the command if it was a System Message
    var message = messageParam as SocketUserMessage;

    if (message == null || message.Author.IsBot) 
       return;

    Console.WriteLine(message.Author);
    time.Start();

    // Create a number to track where the prefix ends and the command begins
    int argPos = 0;

    // Determine if the message is a command, based on if it starts with '!' or a mention prefix
    if (!(message.HasCharPrefix('>', ref argPos))) 
        return;

    // Create a Command Context
    var context = new CommandContext(dbot, message);
    Last = message.Author;

    // Execute the command. (result does not indicate a return value, 
    // rather an object stating if the command executed successfully)
    var result = await commands.ExecuteAsync(context, argPos, services);

    time.Stop();
    time.Reset();
}
它调用这个函数

[Command("ping"), Summary("Echos a message.")]
public async Task Say()
{
    // ReplyAsync is a method on ModuleBase
    await ReplyAsync("PONG " + CommandHandler.time.ElapsedMilliseconds);
}

尝试在异步函数中创建计时器。

启动新线程后,您将直接重置秒表。这意味着如果另一个线程检查该值,秒表已经重置。是否缺少
time.Start()重置计时器后?