Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

which condition should I set Synchronizecallbacks = false

All example code have: 

             digitalReader.SynchronizeCallbacks =

true;

I have just encountered a situation which I have to set 'SynchronizeCallbacks' to false for the callback function to be invoked.

What I do not understand is under which condition I should set this variable to false.

 

0 Kudos
Message 1 of 3
(3,532 Views)

Hi Norman To,

 

The SynchronizeCallbacks specifies how events and callback delegates are invoked. The value should be true if events and callbacks are invoked through the Send or Post methods; otherwise, events and callbacks are invoked directly. The default value is true. In some cases, callbacks and event handlers are executed in a different thread than the rest of the program. Therefore, you must take special care when accessing objects that have thread affinity, such as UI controls, from these callbacks and event handlers. For more information, refer to Events, Callbacks, and Thread Safety in Measurement Studio .NET Class Libraries.

 

Ryan T
National Instruments
Applications Engineer
0 Kudos
Message 2 of 3
(3,502 Views)

Does that means if the acquisition is to be performed in a separated thread than the main program (such as a BackgroundWorker), Synchronizedcallbacks should be set to false.

0 Kudos
Message 3 of 3
(3,494 Views)