Click or drag to resize
Task Scheduler Managed Class Library

SessionStateChangeTrigger Class

Triggers tasks for console connect or disconnect, remote connect or disconnect, or workstation lock or unlock notifications.
Note  Note
Only available for Task Scheduler 2.0 on Windows Vista or Windows Server 2003 and later.
Inheritance Hierarchy
SystemObject
  Microsoft.Win32.TaskSchedulerTrigger
    Microsoft.Win32.TaskSchedulerSessionStateChangeTrigger

Namespace: Microsoft.Win32.TaskScheduler
Assembly: Microsoft.Win32.TaskScheduler (in Microsoft.Win32.TaskScheduler.dll) Version: 2.12.0
Syntax
C#
[XmlTypeAttribute(IncludeInSchema = false)]
public sealed class SessionStateChangeTrigger : Trigger, 
	ITriggerDelay, ITriggerUserId
Request Example View Source

The SessionStateChangeTrigger type exposes the following members.

Constructors
 NameDescription
Public methodSessionStateChangeTriggerCreates an unbound instance of a SessionStateChangeTrigger.
Public methodSessionStateChangeTrigger(TaskSessionStateChangeType, String)Initializes a new instance of the SessionStateChangeTrigger class.
Top
Properties
 NameDescription
Public propertyDelayGets or sets a value that indicates the amount of time between when the system is booted and when the task is started.
Public propertyEnabledGets or sets a Boolean value that indicates whether the trigger is enabled.
(Inherited from Trigger)
Public propertyEndBoundary Gets or sets the date and time when the trigger is deactivated. The trigger cannot start the task after it is deactivated.
Note  Note
While the maximum value for this property is MaxValue, the Windows Task Scheduler management application that is part of the OS will fail if this value is greater than December 31, 9998.

(Inherited from Trigger)
Public propertyExecutionTimeLimit Gets or sets the maximum amount of time that the task launched by this trigger is allowed to run. Not available with Task Scheduler 1.0.
(Inherited from Trigger)
Public propertyIdGets or sets the identifier for the trigger. Cannot set with Task Scheduler 1.0.
(Inherited from Trigger)
Public propertyRepetition Gets a RepetitionPattern instance that indicates how often the task is run and how long the repetition pattern is repeated after the task is started.
(Inherited from Trigger)
Public propertyStartBoundaryGets or sets the date and time when the trigger is activated.
(Inherited from Trigger)
Public propertyStateChangeGets or sets the kind of Terminal Server session change that would trigger a task launch.
Public propertyTriggerTypeGets the type of the trigger.
(Inherited from Trigger)
Public propertyUserId Gets or sets the user for the Terminal Server session. When a session state change is detected for this user, a task is started.
Top
Methods
 NameDescription
Protected methodCheckBindValueChecks the bind value for any conversion.
(Inherited from Trigger)
Public methodCloneCreates a new Trigger that is an unbound copy of this instance.
(Inherited from Trigger)
Public methodCompareTo Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
(Inherited from Trigger)
Public methodCopyProperties Copies the properties from another Trigger the current instance. This will not copy any properties associated with any derived triggers except those supporting the ITriggerDelay interface.
(Overrides TriggerCopyProperties(Trigger))
Public methodDisposeReleases all resources used by this class.
(Inherited from Trigger)
Public methodEquals(Object)Determines whether the specified Object, is equal to this instance.
(Inherited from Trigger)
Public methodEquals(Trigger)Indicates whether the current object is equal to another object of the same type.
(Overrides TriggerEquals(Trigger))
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
Public methodGetHashCodeReturns a hash code for this instance.
(Inherited from Trigger)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Protected methodGetUnboundValueOrDefaultTGets the unbound value or a default.
(Inherited from Trigger)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Protected methodOnNotifyPropertyChangedCalled when a property has changed to notify any attached elements.
(Inherited from Trigger)
Public methodSetRepetitionObsolete.
Sets the repetition.
(Inherited from Trigger)
Public methodToStringReturns a string representing this trigger.
(Inherited from Trigger)
Public methodToString(CultureInfo)Returns a String that represents this trigger in a specific language.
(Inherited from Trigger)
Protected methodV2GetTriggerStringGets the non-localized trigger string for V2 triggers.
(Overrides TriggerV2GetTriggerString)
Top
Events
 NameDescription
Public eventPropertyChangedOccurs when a property value changes.
(Inherited from Trigger)
Top
Fields
 NameDescription
Protected fieldunboundValuesIn testing and may change. Do not use until officially introduced into library.
(Inherited from Trigger)
Top
Remarks
The SessionStateChangeTrigger will fire after six different system events: connecting or disconnecting locally or remotely, or locking or unlocking the session.
Example
C#
new SessionStateChangeTrigger { StateChange = TaskSessionStateChangeType.ConsoleConnect, UserId = "joe" };
new SessionStateChangeTrigger { StateChange = TaskSessionStateChangeType.ConsoleDisconnect };
new SessionStateChangeTrigger { StateChange = TaskSessionStateChangeType.RemoteConnect };
new SessionStateChangeTrigger { StateChange = TaskSessionStateChangeType.RemoteDisconnect };
new SessionStateChangeTrigger { StateChange = TaskSessionStateChangeType.SessionLock, UserId = "joe" };
new SessionStateChangeTrigger { StateChange = TaskSessionStateChangeType.SessionUnlock };
See Also