Class EventSubject
- Namespace
- CsCom.Runtime
- Assembly
- CsCom.Runtime.dll
The base of EventSubject<T>, which completes the observables of an event sink together.
public abstract class EventSubject
- Inheritance
-
EventSubject
- Derived
-
EventSubject<T>
- Inherited Members
Remarks
The completion of a subject is final and removes its observers, so an observer that missed it would never be completed, e.g. one that awaits the last value of an observable. So the exception of an observer stops neither the other observers nor the other subjects: once all of them are completed, the exception is thrown as it is, or an AggregateException of them when several observers threw, like the completions of DisposeWithCompletion(Action).
Methods
Complete(params ReadOnlySpan<EventSubject>)
Completes subjects like OnCompleted(), in their order: every one of them, also when an observer throws. A subject that another call has completed is skipped, also while that call still notifies its observers on another thread.
public static void Complete(params ReadOnlySpan<EventSubject> subjects)
Parameters
subjectsReadOnlySpan<EventSubject>The subjects.
Exceptions
- ArgumentNullException
A subject is null; then no subject is completed.
CompleteAfterAsync(ValueTask, params EventSubject[])
Completes subjects like Complete(params ReadOnlySpan<EventSubject>) once a task has completed, also when it failed, e.g. the
DisposeAsync() of the connection of an event sink. The subjects are completed in the
synchronization context of the caller, e.g. on the thread of a user interface, like the code after an
await.
public static ValueTask CompleteAfterAsync(ValueTask disconnection, params EventSubject[] subjects)
Parameters
disconnectionValueTaskThe task.
subjectsEventSubject[]The subjects.
Returns
- ValueTask
A task that completes once the subjects are completed, but not one that another call is still completing on another thread (see Complete(params ReadOnlySpan<EventSubject>)). It fails with the exception of
disconnectionas it is, e.g. the COMException of a sink that stays connected, or with that of an observer. When several failed, it fails with an AggregateException of them, whose first exception is that ofdisconnection.
Exceptions
- ArgumentNullException
subjectsor a subject is null; thendisconnectionis not awaited, and no subject is completed.