Pocket PC中无毫秒 [英] No Milliseconds in Pocket Pc

查看:148
本文介绍了Pocket PC中无毫秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我用Timer编写Pocket PC应用程序. (Pocket Pc App中没有System.Time).所以我使用Window Timer.我感到惊讶,因为没有毫秒,并且已经返回零.所以我怎么得到毫秒.有人说使用Environment.TickCount.但是我不知道该如何使用,所以请尽可能帮我. :-\

Hello, i write the Pocket Pc Application with Timer. ( There is no System.Time in Pocket Pc App). So I user Window Timer. i amazed ''cause there is no milliseconds and already return zero. So how do i get millisecond. Somebody said use the Environment.TickCount. But i don''t know how do i use so help me if possible. :-\

推荐答案

Environment.TickCount为您提供自系统启动以来经过的毫秒数,该数字将每49.8天从最低值转换为最高值以便使用它.

The Environment.TickCount gives you the number of milliseconds that have elapsed since the system was started the number will cycle from lowest to highest value every 49.8 days so to use it.

Dim startTickCount As Int32 = Environment.TickCount

''Do something here

Dim endTickCount As Int32 = Environment.TickCount



一旦获得了这两个值,就可以使用以下函数来确定经过的毫秒数.



Once you have these two values you could use the following function to determine the number of milliseconds elapsed.

Public Function ElapsedMilliseconds(ByVal StartTickCount As Int32, ByVal EndTickCount As Int32) As Int32
    Dim elapsedTime As Int32 = 0
    If StartTickCount > EndTickCount Then
        elapsedTime = (Int32.MaxValue - StartTickCount) + (EndTickCount - Int32.MinValue)
    Else
        elapsedTime = EndTickCount - StartTickCount
    End If
    Return elapsedTime
End Function


所以有StopWatch类在.NET FrameWork中
没事



So There is StopWatch Class in .NET FrameWork
It is Ok



Dim stopWatch as new StopWatch()

Private Sub Timer_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
       stopWatch.Start()
   
       Dim ts As TimeSpan = stopWatch.Elapsed
       Dim elapsedTime As String = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10)

        txtTimer.Text = elapsedTime
End Sub


这篇关于Pocket PC中无毫秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆