Session Session Session Class


Session is the main object user code interacts with. A Session object represents a row in sys.server_event_sessions and also includes some data from sys.dm_xe_sessions if it's started.

public sealed class Session : Microsoft.SqlServer.Management.Sdk.Sfc.SfcInstance, Microsoft.SqlServer.Management.Common.IAlterable, Microsoft.SqlServer.Management.Common.ICreatable, Microsoft.SqlServer.Management.Common.IDroppable, Microsoft.SqlServer.Management.Sdk.Sfc.ISfcAlterable, Microsoft.SqlServer.Management.Sdk.Sfc.ISfcCreatable, Microsoft.SqlServer.Management.Sdk.Sfc.ISfcDroppable, Microsoft.SqlServer.Management.Sdk.Sfc.ISfcValidate
type Session = class
    inherit SfcInstance
    interface ISfcCreatable
    interface ICreatable
    interface ISfcAlterable
    interface IAlterable
    interface ISfcDroppable
    interface IDroppable
    interface ISfcValidate
    interface ISfcDiscoverObject
Public NotInheritable Class Session
Inherits SfcInstance
Implements IAlterable, ICreatable, IDroppable, ISfcAlterable, ISfcCreatable, ISfcDroppable, ISfcValidate


Session() Session() Session()

Default constructor

Session(BaseXEStore, String) Session(BaseXEStore, String) Session(BaseXEStore, String)

Mostly used constructor


AutoStartProperty AutoStartProperty AutoStartProperty


DefaultDispatchLatency DefaultDispatchLatency DefaultDispatchLatency

Default dispatch latency is 30 seconds.

DefaultMaxMemory DefaultMaxMemory DefaultMaxMemory

The maximum amount of memeory by default is 4 MB.

EventRetentionModeProperty EventRetentionModeProperty EventRetentionModeProperty


InfiniteDispatchLatency InfiniteDispatchLatency InfiniteDispatchLatency

0 indicates that dispatch latency is infinite.

MaxDispatchLatencyProperty MaxDispatchLatencyProperty MaxDispatchLatencyProperty


MaxEventSizeProperty MaxEventSizeProperty MaxEventSizeProperty


MaxMemoryProperty MaxMemoryProperty MaxMemoryProperty


MemoryPartitionModeProperty MemoryPartitionModeProperty MemoryPartitionModeProperty


NotStarted NotStarted NotStarted

Session is currently not running.

TrackCausalityProperty TrackCausalityProperty TrackCausalityProperty


TypeTypeName TypeTypeName TypeTypeName

Type name


AbstractIdentityKey AbstractIdentityKey AbstractIdentityKey Inherited from SfcInstance
AutoStart AutoStart AutoStart

Gets or sets a value indicating whether [auto start].

EventRetentionMode EventRetentionMode EventRetentionMode

Gets or sets the event retention mode.

Events Events Events

Gets the event collection.


Gets the ID.

IdentityKey IdentityKey IdentityKey

Gets the identity key.

IsRunning IsRunning IsRunning

Gets a value indicating whether this session is running.

MaxDispatchLatency MaxDispatchLatency MaxDispatchLatency

Gets or sets the max dispatch latency (in seconds).

MaxEventSize MaxEventSize MaxEventSize

Gets or sets the size (in KB) of the max event.

MaxMemory MaxMemory MaxMemory

Gets or sets the max memory (in KB).

MemoryPartitionMode MemoryPartitionMode MemoryPartitionMode

Gets or sets the memory partition mode.

Metadata Metadata Metadata Inherited from SfcInstance
Name Name Name

The name of the Session

Parent Parent Parent

Gets or sets the parent.

Properties Properties Properties Inherited from SfcInstance
PropertyStorageProvider PropertyStorageProvider PropertyStorageProvider

This property returns the default implementation of SFC for ISfcPropertyStorageProvider interface, it can be overriden in the child classes to return another storage provider (i.e. flat properties list)

(Inherited from SfcInstance)
StartTime StartTime StartTime

Gets the start time.

State State State

State of the object, used in Alter function in session.

Targets Targets Targets
TrackCausality TrackCausality TrackCausality

Gets or sets a value indicating whether [track causality].

Urn Urn Urn

Create a new Urn string on each request and return it.

(Inherited from SfcInstance)


AddEvent(EventInfo) AddEvent(EventInfo) AddEvent(EventInfo)

New an event and add it to this session.

AddEvent(String) AddEvent(String) AddEvent(String)

New an event from fully qualified event name and add it to this session.

AddTarget(String) AddTarget(String) AddTarget(String)

New a target from fully qualified target name and add it to this session .

AddTarget(TargetInfo) AddTarget(TargetInfo) AddTarget(TargetInfo)

New a target and add it to this session.

Alter() Alter() Alter()

Alter the session in the back-end server.

AlterImpl() AlterImpl() AlterImpl() Inherited from SfcInstance
CheckObjectCreated() CheckObjectCreated() CheckObjectCreated()

To be called from domain for when an API requires the object to be Created Stronger than CheckObjectState

(Inherited from SfcInstance)
CheckObjectState() CheckObjectState() CheckObjectState()

To be called from domain for any access to the object

(Inherited from SfcInstance)
Create() Create() Create()

Create the session in the back-end server.

CreateIdentityKey() CreateIdentityKey() CreateIdentityKey() Inherited from SfcInstance
CreateImpl() CreateImpl() CreateImpl() Inherited from SfcInstance
Discover(ISfcDependencyDiscoveryObjectSink) Discover(ISfcDependencyDiscoveryObjectSink) Discover(ISfcDependencyDiscoveryObjectSink) Inherited from SfcInstance
Drop() Drop() Drop()

Drop the session in the back-end server.

DropImpl() DropImpl() DropImpl() Inherited from SfcInstance
GetChildCollection(String) GetChildCollection(String) GetChildCollection(String)

Get the child collection in this instance for the given element name string.

(Inherited from SfcInstance)
GetDomain() GetDomain() GetDomain() Inherited from SfcInstance
GetObjectFactory() GetObjectFactory() GetObjectFactory()

Gets the object factory.

GetPropertySet() GetPropertySet() GetPropertySet() Inherited from SfcInstance
GetTypeMetadataImpl() GetTypeMetadataImpl() GetTypeMetadataImpl() Inherited from SfcInstance
InitializeUIPropertyState() InitializeUIPropertyState() InitializeUIPropertyState()

Overridable from the child objects who care about initializing their states (dynamic metadata which is currently the ".Enabled" property)

(Inherited from SfcInstance)
MarkForDropImpl(Boolean) MarkForDropImpl(Boolean) MarkForDropImpl(Boolean) Inherited from SfcInstance
MarkRootAsConnected() MarkRootAsConnected() MarkRootAsConnected() Inherited from SfcInstance
MoveImpl(SfcInstance) MoveImpl(SfcInstance) MoveImpl(SfcInstance) Inherited from SfcInstance
OnPropertyMetadataChanges(SfcPropertyMetadataChangedEventArgs) OnPropertyMetadataChanges(SfcPropertyMetadataChangedEventArgs) OnPropertyMetadataChanges(SfcPropertyMetadataChangedEventArgs) Inherited from SfcInstance
OnPropertyValueChanges(PropertyChangedEventArgs) OnPropertyValueChanges(PropertyChangedEventArgs) OnPropertyValueChanges(PropertyChangedEventArgs) Inherited from SfcInstance
PostAlter(Object) PostAlter(Object) PostAlter(Object) Inherited from SfcInstance
PostCreate(Object) PostCreate(Object) PostCreate(Object) Inherited from SfcInstance
PostDrop(Object) PostDrop(Object) PostDrop(Object) Inherited from SfcInstance
PostMove(Object) PostMove(Object) PostMove(Object) Inherited from SfcInstance
PostRename(Object) PostRename(Object) PostRename(Object) Inherited from SfcInstance
Refresh() Refresh() Refresh()

refreshes the object's properties by reading them from the server

(Inherited from SfcInstance)
RemoveEvent(Event) RemoveEvent(Event) RemoveEvent(Event)

Removes the event object from the session.

RemoveTarget(Target) RemoveTarget(Target) RemoveTarget(Target)

Removes the target object from this session.

RenameImpl(SfcKey) RenameImpl(SfcKey) RenameImpl(SfcKey) Inherited from SfcInstance
ResetKey() ResetKey() ResetKey() Inherited from SfcInstance
ScriptAlter() ScriptAlter() ScriptAlter()

Script alter for this session.

ScriptCreate() ScriptCreate() ScriptCreate()

Script create for this session.

ScriptDrop() ScriptDrop() ScriptDrop()

Scripts drop for this session

Serialize(XmlWriter) Serialize(XmlWriter) Serialize(XmlWriter) Inherited from SfcInstance
Start() Start() Start()

Starts this session.

Stop() Stop() Stop()

Stops this session.

ToString() ToString() ToString() Inherited from SfcInstance
UpdateUIPropertyState() UpdateUIPropertyState() UpdateUIPropertyState() Inherited from SfcInstance
Validate() Validate() Validate()

Basic child object's validation

(Inherited from SfcInstance)
Validate(String) Validate(String) Validate(String)

Validates the specified method name.

Validate(String, Object[]) Validate(String, Object[]) Validate(String, Object[])

Validates the specified method name.

Explicit Interface Implementations

ISfcDiscoverObject.Discover(ISfcDependencyDiscoveryObjectSink) ISfcDiscoverObject.Discover(ISfcDependencyDiscoveryObjectSink) ISfcDiscoverObject.Discover(ISfcDependencyDiscoveryObjectSink)


propertyChanged propertyChanged propertyChanged Inherited from SfcInstance
PropertyChanged PropertyChanged PropertyChanged Inherited from SfcInstance
propertyMetadataChanged propertyMetadataChanged propertyMetadataChanged Inherited from SfcInstance
PropertyMetadataChanged PropertyMetadataChanged PropertyMetadataChanged Inherited from SfcInstance

Applies to