views:

112

answers:

3

Is there a function which exists in both C# and (unmanaged) C++ which returns a synchronized number (such as float or int)?

For example is there something which brings the exact system time to at least the second which would return the exact same result on both C++ and C# is called in the exact same time?

Just wondering really =)

+1  A: 

Your best bet for a complete sense of control might be to use p/invoke to call a Win32 function like GetSystemTime or GetTickCount directly from C#.

But underneath it all DateTime is just calling Win32 functions, so there's no reason why it's going to give you a significantly different real-time than you'll get using ordinary C-style Win32 calls.

Will Dean
+1  A: 

Are you talking about managed C++ (C++/CLI) or native C++ here? If you're using managed code throughout, then the obvious solution is to utilise the Environment.TickCount property. In native C++, the equivalent is the Win32 API GetTickCount function.

Noldorin
A: 

Managed C++ and C#, most probably. Unmanaged C++, probably not, as it does not compile to IL.

miguel