description | ms.assetid | title | ms.topic | ms.date |
---|---|---|---|---|
The CoCreateActivity function is used to submit batch work to the COM+ system. It allows script-based applications to support an application-wide COM+ service configuration. |
af734507-516c-43f1-9c5e-c77cde1b8008 |
Using COM+ Services Through CoCreateActivity |
article |
05/31/2018 |
The CoCreateActivity function is used to submit batch work to the COM+ system. It allows script-based applications to support an application-wide COM+ service configuration.
The desired COM+ services are configured through a CServiceConfig object that is passed in to the function. The function creates an activity object and returns the IServiceActivity interface of that object. The batch work can be submitted either synchronously or asynchronously, by using the SynchronousCall or AsynchronousCall methods of IServiceActivity, respectively. A pointer to an IServiceCall interface is passed in to each of these methods, and the batch work is implemented by the developer in the OnCall method of the IServiceCall interface.
Does not apply.
Does not apply.
The following code fragment illustrates how to use COM+ services through CoCreateActivity. Error handling is omitted for brevity. This code fragment uses the CServiceConfig object that was created and configured in Configuring COM+ Services with CServiceConfig.
// A CServiceConfig object was created as follows:
// hr = CoCreateInstance(CLSID_CServiceConfig, NULL, CLSCTX_INPROC_SERVER,
// IID_IUnknown, (void**)&pUnknownCSC);
// Create the activity for our services.
HRESULT hr = CoCreateActivity(pUnknownCSC, IID_IServiceActivity, (void**)&pActivity);
if (FAILED(hr)) throw(hr);
// Do the batch work synchronously.
// The batch work is implemented in pServiceCall->OnCall().
hr = pActivity->SynchronousCall(pServiceCall);
if (FAILED(hr)) throw(hr);