Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

GPIB .NET Threading Issues

Hello everyone,
 
Does anyone know the work-around for this:
 
In C# .NET (2003), I have a couple of back-ground threads running (let's say one DAQ and one CAN) in my application. I want to be able to change some setting on my signal generator (via GPIB). Every time I need to GPIB write / read from the signal generator, I need to kill the DAQ and CAN threads before I can do any GPIB communication. Also, in doing any GPIB communication, while my DAQ and CAN threads are running, kill the DAQ and CAN threads.
Can anyone shine some light on the subject?
 
Thanks much!
0 Kudos
Message 1 of 2
(3,201 Views)
Jay,

Is it necessary for you to kill those threads?  It might be better to have a variable that you use to communicate to the DAQ and CAN threads.  That way, when you want to change the settings for your signal generator, you would set the variable, writing_to_gpib to true.  In your DAQ and CAN threads, the while loop conditional could check that writing_to_gpib is false before they continue they're acquisitions.  After you are done communicating with the GPIB device, you can set writing_to_gpib back to false.  In the DAQ and CAN threads then you can enter back into the acquistion/generation loop.  It might be easier than having to reinitialize your DAQ and CAN devices everytime.  The variable could either be a static global, or you can pass the reference to the other threads.  I'm not sure if this would work for your situation, but it may be a cleaner way to approach the problem.

Tyler T.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 2
(3,173 Views)