Serves instead of a standard event handler to avoid maintaining a strong reference to the handler target causing a possible memory leak.
Public Member Functions |
|
WeakEventHandler (Delegate handler) | |
Construct from an event handler Delegate.
|
|
void | Invoke (params Object[] args) |
Invokes this event handler. |
|
Properties |
|
WeakReference |
TargetReference [get, set] |
WeakReference to the listening object.
|
|
MethodInfo |
TargetMethod [get, set] |
The handler method. |
|
bool |
IsAlive [get] |
Is the WeakReference target still alive?
|
CSharpUtilities::WeakEventHandler::WeakEventHandler | ( | Delegate | handler | ) | [inline] |
Construct from an event handler Delegate.
handler | Event handler. |
void CSharpUtilities::WeakEventHandler::Invoke | ( | params Object[] | args | ) | [inline] |
Invokes this event handler.
Does not check if the TargetReference is alive. It is up to the caller to check IsAlive first.
args | Function arguments to pass to the event listener. |
WeakReference
CSharpUtilities::WeakEventHandler::TargetReference [get,
set] |
WeakReference to the listening object.
MethodInfo
CSharpUtilities::WeakEventHandler::TargetMethod [get,
set] |
The handler method.
bool CSharpUtilities::WeakEventHandler::IsAlive
[get] |
Is the WeakReference target still alive?