VSABeginSession

See Also      Example   

Starts a Visual Studio Analyzer session with the calling component. You assign a unique identifier to the session. Events that are generated during this session are stamped with the session identifier, which helps you identify the true source of an event, particularly in cases where multiple copies of the component are running at the same time.

Syntax

HRESULT VSABeginSession ([in] long vaaId,
[in, string] wchar_t
*guidSourceID,
[in, string] wchar_t
*strSessionName);

Parameters

vaaId

Unique identifier for this session of the component. This identifier is returned when you call VSAOpenConnection.

guidSourceID

A unique identifier for this component. Multiple sessions from this component can exist at the same time on the same machine. This ID is defined when you register a component with Visual Studio Analyzer.

strSessionName

A session identifier, which must be unique among all instances of this component until the machine is restarted.

Remarks

Each Visual Studio Analyzer in-process event creator object can accept only one call to BeginSession. If your object supports multiple simultaneous sessions, such as a Web server running on more than one port, you can choose to create multiple in-process event creator objects.

The code does not validate whether strSessionName is unique. If it is not unique, the user might be unable to distinguish events from the two sessions. This lack of checking allows for two servers that represent one conceptual session to coexist and operate correctly.

This function will fail if guidSourceID is not properly registered.

You can use the default user component, DEBUG_EVENT_SOURCE_USER, which is already registered, if you want a quick way to generate events without a lot of overhead. The default user component is registered automatically when you install Visual Studio Analyzer.

You can make repeated calls to BeginSession and EndSession on the same object, as long as you have a matching BeginSession call for each EndSession call. You cannot nest calls.

Accepted Not Accepted
BeginSession BeginSession
EndSession BeginSession
BeginSession EndSession
EndSession EndSession