# CmtNewTSV

int CmtNewTSV (int variableSize, int *variableHandle);

## Purpose

Creates a thread safe variable.

Use a thread safe variable to store information that must be accessed from more than one thread in your application. When you finish using the variable from all threads, you must call CmtDiscardThreadSafeVar to uninitialize the thread safe variable.

It is difficult to program with this function directly. It is easier to program with the functions provided by the DefineThreadSafeScalarVar, DeclareThreadSafeScalarVar, DefineThreadSafeScalarVar, and DeclareThreadSafeScalarVar macros, which are defined in utility.h.

## Parameters

Input
Name | Type | Description
variableSize | integer | The size, in bytes, of the data that you want to store in the thread safe variable. The sizeof operator is useful for this.
Output
Name | Type | Description
variableHandle | integer (passed by reference) | Returns a handle that you use to identify the thread safe variable in subsequent function calls. The handle is never 0.

## 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.