# ctaDestroyQueue

Destroys all contexts created on the event queue, closes services, and destroys the queue.

#### Prototype

DWORD ctaDestroyQueue ( CTAQUEUEHD ctaqueuehd)

Argument | Description
ctaqueuehd | Handle returned by ctaCreateQueue.

#### Return values

Return value | Description
SUCCESS |
CTAERR_INVALID_CTAQUEUEHD | Already destroying the queue.
CTAERR_NOT_INITIALIZED | Natural Access is not initialized. Call ctaInitialize first.

#### Details

ctaDestroyQueue destroys all contexts created on the event queue, closes all services, and destroys the queue. Since this is a synchronous function, the application remains blocked until all cleanup and close activity is completed.

If any errors are returned other than those listed in the Return values section, ctaDestoyQueue had problems destroying the queue. Resources may be left in an unknown state.

Refer to Closing services for more information.

#### See also

ctaDestroyContext

#### Example

/* Shutdown the state machine demo. */
void DemoShutdown(CTAQUEUEHD ctaqueuehd)
{
unsigned i;
/* Destroying the queue will destroy all contexts created on the queue. */
ctaDestroyQueue( ctaqueuehd );
/* Free all the contexts. */
for (i=0; i < 100; i++)
{
if (Cxarray[i] != NULL)
free ( Cxarray[i] );
}
}