Admin Production ni-theme
Current Publication

CA_SetSupportForMultithreading

LabWindows/CVI

CA_SetSupportForMultithreading

HRESULT CA_SetSupportForMultithreading (CAObjHandle objectHandle, int supportMultithreading);

Purpose

Sets whether you will use this object handle from threads other than the thread in which the object was created.

CA_SetSupportForMultithreading must be called from the same thread in which the object is created and before it is passed to any ActiveX Library functions.

Parameters

Input
Name Type Description
objectHandle CAObjHandle ActiveX object handle returned by one of the object creation functions in this library or by an ActiveX server method.
supportMultithreading int Specify a nonzero value or select Yes in the function panel to use the object from multiple threads.

Specify 0 or select No in the function panel to use the object only from the thread that calls this function.

The ActiveX Library uses the COM Global Interface Table (GIT) to allow you to use an object handle from threads other than the thread in which it was created. There is overhead associated with using the GIT, which you should try to avoid when possible. If you do not pass the CAObjHandle between threads in your application, you do not need to use the GIT, and you can pass 0 for this parameter.

You do not need to use the GIT if all of the threads in which you use an object handle belong to the multithreaded apartment. You can call CA_InitActiveXThreadStyleForCurrentThread with COINIT_MULTITHREADED as the threading style. Refer to www.msdn.com for more information about threads and apartments.

Return Value

Name Type Description
status HRESULT A value indicating whether an error occurred. Negative error codes indicate function failure.

Error codes are defined in CVIversion\include\cviauto.h and <Program Files>\National Instruments\Shared\MSDTRedistributables\SDKHeaderFiles\8.1\winerror.h. The LabWindows/CVI ActiveX Library explicitly returns error codes. Other error codes in winerror.h are generated by ActiveX servers and passed on to you by the LabWindows/CVI ActiveX Library.

You can use CA_GetAutomationErrorString to get the description of an error code or CA_DisplayErrorInfo to display the description of the error code.

Additional Information

Library: ActiveX Library

Include file: cviauto.h

LabWindows/CVI compatibility: LabWindows/CVI 5.5 and later