This topic has not yet been rated - Rate this topic

CoCreateActivity function

Applies to: desktop apps only

Creates an activity to do synchronous or asynchronous batch work that can use COM+ services without needing to create a COM+ component.

Syntax

HRESULT __stdcall CoCreateActivity(
  __in   IUnknown *pIUnknown,
  __in   REFIID riid,
  __out  void **ppObj
);

Parameters

pIUnknown [in]

A pointer to the IUnknown interface of the object, created from the CServiceConfig class, that contains the configuration information for the services to be used within the activity created by CoCreateActivity.

riid [in]

The ID of the interface to be returned through the ppObj parameter. This parameter should always be IID_IServiceActivity so that a pointer to IServiceActivity is returned.

ppObj [out]

A pointer to the interface of an activity object. The activity object is automatically created by the call to CoCreateActivity.

Return value

This method can return the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_FAIL, as well as the following values.

Return codeDescription
S_OK

The method completed successfully.

CO_E_SXS_CONFIG

The side-by-side assembly configuration of the CServiceConfig object is invalid.

CO_E_THREADPOOL_CONFIG

The thread pool configuration of the CServiceConfig object is invalid.

CO_E_TRACKER_CONFIG

The tracker configuration of the CServiceConfig object is invalid.

COMADMIN_E_PARTITION_ACCESSDENIED

The caller does not have access permissions for the COM+ partition.

 

Remarks

CoCreateActivity creates an activity object that is used to submit batch work to the COM+ system. The context associated with the activity is completely determined by the CServiceConfig object that is passed through the pIUnknown parameter.

CoCreateActivity enables applications to use COM+ services in their batch work without needing to create a component to use those services. In addition to reducing overhead by not requiring the creation of a component, using CoCreateActivity provides for a more efficient runtime environment because it allows the environment to support application-wide service configuration without needing to access information that is stored in the COM+ registration database (RegDB).

The batch work that is submitted through CoCreateActivity can be either synchronous or asynchronous and can run in either a single-threaded apartment (STA) or the multithreaded apartment (MTA). The threading model that is used is determined by the IServiceThreadPoolConfig interface of the CServiceConfig object that is passed through the pIUnknown parameter.

CoCreateActivity returns a pointer to the IServiceActivity interface of the object that is created by the call to CoCreateActivity. By using the methods of IServiceActivity, you determine whether the batch work is done synchronously or asynchronously. The batch work itself is implemented through the IServiceCall interface.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

ComSvcs.h

Library

ComSvcs.lib

DLL

ComSvcs.dll

See also

CoEnterServiceDomain
CoLeaveServiceDomain
COM+ Services Without Components
CServiceConfig
IServiceActivity
IServiceCall

 

 

Send comments about this topic to Microsoft

Build date: 2/3/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ