Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WinRT Replacement of System.Environment.TickCount

What is the WinRT replacement for System.Environment.TickCount?

like image 207
Nick Banks Avatar asked Apr 29 '12 02:04

Nick Banks


2 Answers

It should be available, because it isn't a problem. But it is not, a [TypeForwardedTo] hangup I guess because GetTickCount() isn't on the white list and .NET never adopted GetTickCount64. The standard fallback works fine, you can use pinvoke the call the native Windows function. I verified that a program that uses it passes the Windows App Certification Kit test.

    [System.Runtime.InteropServices.DllImport("kernel32.dll")]
    private static extern long GetTickCount64();

Note that it returns a long, not an int. You can simply cast to int to truncate if that's important in C# (but not vb.net, just lie about the return type)

like image 52
Hans Passant Avatar answered Nov 15 '22 17:11

Hans Passant


It appears System.Environment.TickCount is supported in Windows 8 Windows store apps now.

like image 40
Anthony Wieser Avatar answered Nov 15 '22 16:11

Anthony Wieser