IServiceActivity::BindToCurrentThread method (comsvcs.h)

Binds the user-defined batch work to the current thread.

Syntax

HRESULT BindToCurrentThread();

Return value

This method can return the standard return values E_INVALIDARG, E_OUTOFMEMORY, E_FAIL, and S_OK.

Remarks

This method binds the batch work that is submitted via the AsynchronousCall or the SynchronousCall method to the current single-threaded apartment (STA). It has no effect if the current thread is being run in the multithreaded apartment (MTA). The current thread model is determined by the configuration of the IServiceThreadPoolConfig interface of the CServiceConfig object that is passed via the pIUnknown parameter during the call to CoCreateActivity.

Calling this method is equivalent to having called IServiceThreadPoolConfig::SetBindingInfo with CSC_BindToPoolThread on the CServiceConfig object that was passed through the pIUnknown parameter to CoCreateActivity. However, after the activity has been created by CoCreateActivity, you can no longer call IServiceThreadPoolConfig::SetBindingInfo to change the thread binding. To change the thread binding after the activity has been created, you must call the BindToCurrentThread or the UnbindFromThread method of IServiceActivity.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header comsvcs.h

See also

IServiceActivity