Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Measurement Studio: Is there a way to use C++ libs in C# code?

I'd like to use the CNiTimer class, but I'm writing my code in C#. Can this be done?
0 Kudos
Message 1 of 8
(4,774 Views)
This should be possible, but would not be trivial to implement. You would need to create a DLL that exposes the CNiTimer functionality that you are interested in. The DLL would need to expose the functionality through C entry points. You could then call the C DLL through .NET interop. Things will be further complicated if you will need to respond to callbacks from CNiTimer.

This does not seem to me to be the right approach. Your best bet should be to use a native .NET framework timer. Check out System.Threading.Timer, System.Windows.Forms.Timer, and the classes in the System.Timer namespace. What functionality from CNiTimer do you want that is not available in a native .NET framework timer?
0 Kudos
Message 2 of 8
(4,774 Views)
Thanks for the answer.
First of all, I'm new to Visual Studio and Measurement Studio.
I was looking for a very simple delay function call, with only a single parameter. The CNiTimer Class fit the bill. The .NET framework allows me to create a Monitor object, and then use a Wait member function, but then I have to associate an object with the function, and things now become a bit more complicated.
I created my own using DateTime.Now
Thanks for the help.
0 Kudos
Message 3 of 8
(4,774 Views)
If I correctly understand what you are trying to do, you could use System.Thread.Sleep().
0 Kudos
Message 4 of 8
(4,774 Views)
For a simple delay, does the Thread.Sleep method accomplish what you're looking for?

- Elton
0 Kudos
Message 5 of 8
(4,774 Views)
Thanks,
Remember, I'm learning.
Thanks a lot,
Dennis
0 Kudos
Message 6 of 8
(4,774 Views)
Yes, it works just fine.
Thanks,
Dennis
0 Kudos
Message 7 of 8
(4,774 Views)
Thisdocument might help you as well. It lists the Win32 functions and its equivalent function in the .NET framework. Nice place to start looking for functions.

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 8 of 8
(4,774 Views)