# CmtDiscardThreadLocalVar

int CmtDiscardThreadLocalVar (int variableHandle);

## Purpose

Destroys a thread local variable and frees the resources used by it.

After you call this function, you can no longer access the thread local variable from any thread.

This function calls the discardCallbackFunction parameter, which you specified in CmtNewThreadLocalVar, once for each thread that accessed the thread local variable. Note that CmtDiscardThreadLocalVar calls the callback in the thread that calls CmtDiscardThreadLocalVar, and not in the individual threads that accessed the thread local variable. Therefore, if you use the thread local variable to store a resource that must be freed from the thread that created it, you must use PostDeferredCallToThread to notify the proper thread that it must clean up the resource.

## Parameters

Input
Name | Type | Description
variableHandle | integer | The handle you obtained from CmtNewThreadLocalVar to identify the thread local variable.

## Return Value

Name | Type | Description
CmtStatus | integer | The CmtStatus code that the function call returns. This function returns 0 to indicate success and negative values to indicate failure. Pass the CmtStatus code to CmtGetErrorMessage to get a description of the error code.