Weak |
The WeakEventSourceTEventArgs type exposes the following members.
Name | Description | |
---|---|---|
WeakEventSourceTEventArgs | Initializes a new instance of the WeakEventSourceTEventArgs class |
Name | Description | |
---|---|---|
Raise | Raises the event with the specified sender and argument. | |
Subscribe | Subscribes the specified handler for the event. | |
Unsubscribe | Unsubscribes the specified handler from the event. |
Name | Description | |
---|---|---|
SafeCastT |
Performs a cast from object to T, avoiding possible null violations if T is a value type.
(Defined by ObjectExtensions) |
class SampleSource { private readonly WeakEventSource<EventArgs> _source = new WeakEventSource<EventArgs>(); public event EventHandler AnyAction { add => _source.Subscribe(value); remove => _source.Unsubscribe(value); } private void OnAnyAction() { _source.Raise(this, EventArgs.Empty); } } class SampleSink { public SampleSink() { var source = new SampleSource(); source.AnyAction += Source_AnyAction; } private void Source_AnyAction(object sender, EventArgs e) { ... do something } }