Destroys a context.
DWORD ctaDestroyContext ( CTAHD ctahd)
|
Argument |
Description |
|
ctahd |
Context handle. |
|
Return value |
Description |
|
SUCCESS |
|
|
CTAERR_INVALID_CTAHD |
|
|
CTAERR_INVALID_SEQUENCE |
There is a pending open service, close service, or destroy context call on the context. |
|
CTAERR_NOT_INITIALIZED |
Natural Access is not initialized. Call ctaInitialize first. |
|
CTAERR_SVR_COMM |
Server communication error. |
CTAEVN_DESTROY_CONTEXT_DONE
This function destroys the context and closes all open services opened on that context. This function is asynchronous and returns immediately. The application must wait for the DONE event before the context is destroyed and any resources associated with it are released.
Since ctaDestroyContext closes all services, there can be no pending open or close service calls. Wait until the pending function completes and then call this function.
If an application sets the CTA_CONTEXT_PERSISTENT flag in ctaCreateContextEx, the shared context continues to exist on the server even when the originating application is disconnected. When the last application attached to the context calls ctaDestroyContext, the context is destroyed.
Refer to Closing services, and destroying contexts and event queues for more information.
ctaAttachContext, ctaCreateContext, ctaCreateContextEx
/*
* Destroy the context and the queue. It would be equivalent to just
* destroy the queue since this implicitly destroys the context and
* closes all open services.
*/
void DemoDestroyContext(DEMOCONTEXT *cx)
{
CTA_EVENT event;
/* Destroy the context */
ctaDestroyContext( cx->ctahd );
/* Wait for the services to be closed and the context destroyed */
do
{
ctaWaitEvent( cx->ctaqueuehd, &event, CTA_WAIT_FOREVER );
} while (event.id != CTAEVN_DESTROY_CONTEXT_DONE);
ctaDestroyQueue( cx->ctaqueuehd );
}