Click or drag to resize

SuspendableObject Class

Helper class to suspend and resume change events (or other events). This class keeps a counter variable (suspend counter), which is incremented when a call to SuspendGetToken has been made, and is decremented when the suspend token returned by this call is disposed. Although you can use this class as it is - to keep track of the number of suspends - it is designed to be used in derived classes. See the remarks on details of the functions you should override.
Inheritance Hierarchy
SystemObject
  Altaxo.MainSuspendableObject
    Altaxo.MainTemporaryDisabler

Namespace: Altaxo.Main
Assembly: AltaxoBase (in AltaxoBase.dll) Version: 4.8.3179.0 (4.8.3179.0)
Syntax
C#
public class SuspendableObject : ISuspendableByToken

The SuspendableObject type exposes the following members.

Constructors
 NameDescription
Public methodSuspendableObjectInitializes a new instance of the SuspendableObject class
Top
Properties
 NameDescription
Public propertyIsSuspended Gets a value indicating whether this instance is suspended.
Top
Methods
 NameDescription
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
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 methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Protected methodOnAboutToBeResumed Is called when the suspend level is still 1 (one), but is about to fall to zero, i.e. shortly before the call to OnResume. This function is not called before OnResumeSilently!
Protected methodOnResume Is called when the suspend level falls down from 1 to zero by a call to Resume or a call to Dispose.
Protected methodOnResumeSilently Is called when the suspend level falls down from 1 to zero by a call to ResumeSilently. The implementation should delete any accumulated events, should also disarm the suspendTokens of the childs of this object, and should not fire any Changed events nor set the change state of the object to dirty.
Protected methodOnSuspended Called when the suspend level has just gone from 0 to 1, i.e. the object was suspended.
Public methodResume(ISuspendToken) Decrease the suspend level by disposing the suppress token. The token will fire the Resume event if the suppress level falls to zero.
Public methodResume(ISuspendToken, EventFiring) Decrease the suspend level by disposing the suppress token. The token will fire the Resume event if the suppress level falls to zero. You can suppress the resume event by setting argument 'suppressResumeEvent' to true.
Public methodResumeShortlyGetToken Resumes the events of this class as long as you hold the returned resume token. The original state (the suspenended state) is restored when you dispose the resume token.
Public methodSuspendGetToken Increase the SuspendLevel by one, and return a token that, if disposed, will resume the object.
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Top
Remarks
There are four functions which can be overridden. In this class, these functions do nothing.
  • OnSuspended is called when the suspend counter has been incremented from 0 to 1, i.e. the instance is suspended now.
  • OnAboutToBeResumed is called when the suspend counter is still 1, i.e. the instance is still suspended, but the suspend counter will afterwards be decremented to 0.
  • OnResume is called when the suspend counter has been decremented to 0, i.e. the instance is resumed now, and should fire events again. It should also fire a change event if something has changed during the suspended state.
  • OnResumeSilently is called when the suspend counter has been decremented to 0 as result of a call to ResumeSilently
See Also