Click or drag to resize
CallLimiter Class
Class which limits calls to a method by using a timer which effectively calls the method instead. To limit calls to a given method, pass it as a lambda to the method Call(Action, Double, ISynchronizeInvoke). The first time Call(Action, Double, ISynchronizeInvoke) is called, a timer is started and the lambda is stored. When the timer elapses after the specified number of milliseconds, the stored lambda is called and the timer is reset, though not started again. When Call(Action, Double, ISynchronizeInvoke) is called while the timer is running (so between the first call and the moment the timer elapses) the call is ignored. This way you can limit calls to a given method to 1 per interval. This is useful for situation where you have a lot of events coming from different sources which all result in a single call to a given method.
Inheritance Hierarchy
SystemObject
  SD.Tools.Algorithmia.GeneralDataStructuresCallLimiter

Namespace:  SD.Tools.Algorithmia.GeneralDataStructures
Assembly:  SD.Tools.Algorithmia (in SD.Tools.Algorithmia.dll) Version: 1.2.0.0 (1.2.16.0406)
Syntax
public class CallLimiter

The CallLimiter type exposes the following members.

Constructors
  NameDescription
Public methodCallLimiter
Initializes a new instance of the CallLimiter class.
Top
Methods
  NameDescription
Public methodCall(Action)
Calls the specified to call after 500ms milliseconds, unless a call is already in progress, in which case the call is ignored. It doesn't matter if this method was called previously with a different toCall value.
Public methodCall(Action, Double)
Calls the specified to call after intervalMS milliseconds, unless a call is already in progress, in which case the call is ignored. It doesn't matter if this method was called previously with a different toCall value.
Public methodCall(Action, Double, ISynchronizeInvoke)
Calls the specified to call after intervalMS milliseconds, unless a call is already in progress, in which case the call is ignored. It doesn't matter if this method was called previously with a different toCall value.
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
Remarks
Be aware that if no synchronizationcontext is specified, the call to the lambda specified to Call(Action, Double, ISynchronizeInvoke) will be done on another thread, namely the one the timer runs on
See Also