Click or drag to resize

EventThrottlerTElement, TEventArgs Class

Class which throttles an event pipeline. It offers unique event raising during a fixed interval. Instances collect events and with each interval only the unique events (last event first) from that batch are raised. Every event found in the batch which is equal to an already raised event (which has equal event arguments) is ignored. Use this class to limit a large amount of events which are equal and lead to e.g. repainting a UI, to act like a event instead. This can greatly increase performance in scenarios where events are used to manipulate UI objects or other objects and repetitive changes lead to the same situation (e.g. 100 times the event that an element has changed in a short time (e.g. 100ms) where each time a TreeNode is repainted because 'the element has changed' is redundant: the last event in the batch is enough, it already repaints the node completely).

Events are compared based on the event args, which are compared to event arguments already processed. Use one throttler per event handler.
Inheritance Hierarchy
SystemObject
  SD.Tools.Algorithmia.GeneralDataStructuresEventThrottlerTElement, TEventArgs

Namespace:  SD.Tools.Algorithmia.GeneralDataStructures
Assembly:  SD.Tools.Algorithmia (in SD.Tools.Algorithmia.dll) Version: 1.3.3.0 (1.3.18.0209)
Syntax
public class EventThrottler<TElement, TEventArgs>
where TElement : class
where TEventArgs : EventArgs

Type Parameters

TElement
The type of the element involved in the event. If possible, use a more specific object than the event sender.
TEventArgs
The type of the event args.

The EventThrottlerTElement, TEventArgs type exposes the following members.

Constructors
  NameDescription
Public methodEventThrottlerTElement, TEventArgs(ISynchronizeInvoke)
Initializes a new instance of the EventThrottlerTElement, TEventArgs class.
Public methodEventThrottlerTElement, TEventArgs(ISynchronizeInvoke, Int32)
Initializes a new instance of the EventThrottlerTElement, TEventArgs class.
Public methodEventThrottlerTElement, TEventArgs(ISynchronizeInvoke, Int32, IEqualityComparerTEventArgs)
Initializes a new instance of the EventThrottlerTElement, TEventArgs class.
Top
Properties
  NameDescription
Public propertyEnabled
Gets or sets a value indicating whether this EventThrottlerTElement, TEventArgs is enabled. If disabled, it simply re-raises the events enqueued.
Top
Methods
  NameDescription
Public methodClear
Clears this instance's queued tasks and stops the timer, if it was set.
Public methodEnqueueEvent
Enqueues the event in the task queue.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Events
  NameDescription
Public eventEventThrottled
Raised when a unique event was throttled from the task queue and approved to be processed by observers.
Public eventQueueProcessingFinished
Raised when the queue processing was finished.
Public eventQueueProcessingStarted
Raised when the queue processing was started.
Top
See Also