vb.net - 如何在 Visual Studio 中使用多个计时器?

标签 vb.net visual-studio-2013 vbscript timer

我正在开发一个测验游戏,我想计算每个问题所需的时间。我正在考虑一个基本的解决方案,即在为用户生成问题时启动timer2,然后在用户选择答案时停止timer2,最后在标签中显示timer2 所用的时间。

但是今天我意识到在 Visual Studio 中不能使用两个以上的计时器,因为在 Visual Studio 中只能同时运行一个计时器。

顺便说一句,在我的问答游戏中,timer1 被用作倒计时器。

所以,我的问题是如何在 Visual Studio 2013 上同时运行两个计时器?

谢谢。

enter image description here

最佳答案

计时器是不适合这项工作的工具。也许对于整体倒计时器来说这是可以的,因为您本质上是在说“在 y 时间段后触发 x 事件”。但要测量某件事花费了多长时间,您应该使用秒表

// at start of the question
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();

// when they select an answer
stopwatch.Stop();

// example of getting time taken
stopwatch.ElapsedMilliseconds;

PS:秒表一次不限于一个。

关于vb.net - 如何在 Visual Studio 中使用多个计时器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31874919/

相关文章:

java - 如何在 VB.net 表单中打开 .jar?

c# - 在 VS 2013 中使用报表查看器

c++ - LNK2005,C++/CLI,不知道

debugging - 无法对 Azure 云服务使用远程调试,符号尚未加载

vb.net - 使用命令行将 *.xls 或 *.xlsx 文件转换为管道分隔的 .csv 文件

mysql - Visual Basic从MySQL读取tinyint

c# - 在 ASP、C# 和 VB.Net 中如何检索当前行号

html - 对象不支持此属性或方法 - InnerHTML VBS HTA 问题

powershell - 通过 powershell 或 vbscript 以编程方式将现有的 ssl 证书分配给 iis6 中的网站

.net - 如何在 VB.NET 中为静态类编写方法扩展?