Switch Members

The Switch type exposes the following members.

Constructors


  Name Description
Public method Switch

Methods


  Name Description
Public method Equals(System.Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected method Finalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public method GetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public method GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public method IfOff
Executes the provided action and returns if the action was executed or not, if the switch is IMMEDIATELY off (i.e. no lock involved)
Public method IfOn
Executes the provided action and returns if the action was executed or not, if the switch is IMMEDIATELY on (i.e. no lock involved)
Protected method MemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public method SwitchOff(Action)
Executes the provided action if the lock is on. This is done under a lock so be _very_ careful with longrunning/blocking operations in it. Only executes the action if the switch is on, and switches it off immediately after obtaining the lock. Will switch it back on if the provided action throws an exception.
Public method SwitchOff()()()()
Switches the switch off (if on). Uses locking.
Public method SwitchOn(Action)
Executes the provided action if the lock is off. This is done under a lock so be _very_ careful with longrunning/blocking operations in it. Only executes the action if the switch is off, and switches it on immediately after obtaining the lock. Will switch it back off if the provided action throws an exception.
Public method SwitchOn()()()()
Switches the switch on (if off). Uses locking.
Public method ToString
Returns a string that represents the current object.
(Inherited from Object.)
Public method WhileOff
Executes the provided action and returns if the action was executed or not, if the switch is off, waiting for any pending changes to happen before (locking) Be careful of longrunning or blocking within the provided action as it can lead to deadlocks or bad performance
Public method WhileOn
Executes the provided action and returns if the action was executed or not, if the switch is on, waiting for any pending changes to happen before (locking) Be careful of longrunning or blocking within the provided action as it can lead to deadlocks or bad performance

Properties


  Name Description
Public property IsOff
Gets a value indicating whether this switch is off. No locking.
Public property IsOn
Gets a value indicating whether this switch is on. No locking.