Silverlight 的秒表? [英] Stopwatch for silverlight?
本文介绍了Silverlight 的秒表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Silverlight 没有秒表.
There is no StopWatch for Silverlight.
你会用什么来代替它?
我看到一些关于人们说要创建一个空动画并从 Storyboard 类调用 GetCurrentTime() 的帖子,我无法让它工作......
I saw some posts about people saying to create an empty animation and call GetCurrentTime() from the Storyboard class, I couldn't get it to work...
你会怎么做?
推荐答案
这就是我所做的.它很简单,对我来说效果很好:
This is what I did. Its simple and worked very well for me:
long before = DateTime.Now.Ticks;
DoTheTaskThatNeedsMeasurement();
long after = DateTime.Now.Ticks;
TimeSpan elapsedTime = new TimeSpan(after - before);
MessageBox.Show(string.Format("Task took {0} milliseconds",
elapsedTime.TotalMilliseconds));
在开始目标任务之前,您需要做的就是保持一个长变量来保存总滴答数.
All you needed to do was keep one long variable holding the total ticks before beginning the target task.
这篇关于Silverlight 的秒表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文