Multifunction DAQ

Showing results for 
Search instead for 
Did you mean: 

Problem with setting SynchronizingObject for Async Daq read

I am setting up DAQ class with an asynchronous read. I am setting it up just like NI example program:

...DAQmx\Analog In\Measure Voltage\ContAcqVoltageExtClk_DigStart\Vb

I then take my class, which has a function that starts the BeginReadMultiSample, and create an instance of it in another project. Now when I run the line "myReader.SynchronizingObject = Me", I get an InvalidCastException: specified cast is not valid. Any ideas what I need to set this to when using and instance of my class?
0 Kudos
Message 1 of 4
Hello Noja,

The SynchronizingObject property needs an object that implements the ISynchronizeInvoke interface. You might be trying to implement the functionality into your own class and then trying to assign this class to the property without implementing the interface. Hence the error. It works in the examples because Me is referring to the Form class. And this class does implement this interface.

Check out these links:

You should also check out the DAQmx .NET Framework Help topic Asynchronously Reading and Writing with the NI-DAQmx .NET Class Library. This can be accessed at Start >> Programs >> National Instruments >> NI-DAQ >> DAQmx .NET Framework Help.

Please look through these help documents as thoroughly as possible, as this seems to be a .NET coding issue more than a NI-DAQ issue.

I hope this helps,
Sean C.
0 Kudos
Message 2 of 4
The Start >> Programs >> National Instruments >> NI-DAQ >> DAQmx .NET Framework Help is not in my start menu. All i have is C referance help files. Can I get this file from
0 Kudos
Message 3 of 4
We updated this shortcut for DAQ 7.4, which is the newest driver release. If you have an older version, you wont have this.

This help file is integrated into the Visual Studio .NET documentation. In Visual Studio .NET, select Help» Contents.

To view the NI-DAQmx .NET Library help, select NI Measurement Studio Help»NI Measurement Studio .NET Class Library»Reference»National Instruments.DAQmx.

For tasks and concepts, select NI Measurement Studio Class .NET Library»Using the Measurement Studio .NET Class Libraries»Using the Measurement Studio NI-DAQmx .NET Library.

Hope this helps.
Bilal Durrani
0 Kudos
Message 4 of 4