},System.Linq.Expressions.Expression{System.Action{System.Action}})} },System.Linq.Expressions.Expression{System.Action{System.Action}},System.Reactive.Concurrency.IScheduler)} },System.Linq.Expressions.Expression{System.Action{--0}})} },System.Linq.Expressions.Expression{System.Action{--0}},System.Reactive.Concurrency.IScheduler)} ,--0}},System.Linq.Expressions.Expression{System.Action{--0}},System.Linq.Expressions.Expression{System.Action{--0}})} ,--0}},System.Linq.Expressions.Expression{System.Action{--0}},System.Linq.Expressions.Expression{System.Action{--0}},System.Reactive.Concurrency.IScheduler)} }},System.Linq.Expressions.Expression{System.Action{System.Action{--0}}})} }},System.Linq.Expressions.Expression{System.Action{System.Action{--0}}},System.Reactive.Concurrency.IScheduler)}
Qbservable.FromEvent(IQbservableProvider, Expression>, Expression>) method¶
Defined in
Type: Qbservable
Namespace: System.Reactive.Linq
Assembly: System.Reactive.dll
Applies to
netstandard2.0
Overloads¶
- 1.
public static IQbservable<Unit> FromEvent(this IQbservableProvider provider, Expression<Action<Action>> addHandler, Expression<Action<Action>> removeHandler) - 2.
public static IQbservable<Unit> FromEvent(this IQbservableProvider provider, Expression<Action<Action>> addHandler, Expression<Action<Action>> removeHandler, IScheduler scheduler) - 3.
public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler) - 4.
public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler) - 5.
public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<Action<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler) - 6.
public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<Action<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler) - 7.
public static IQbservable<TEventArgs> FromEvent<TEventArgs>(this IQbservableProvider provider, Expression<Action<Action<TEventArgs>>> addHandler, Expression<Action<Action<TEventArgs>>> removeHandler) - 8.
public static IQbservable<TEventArgs> FromEvent<TEventArgs>(this IQbservableProvider provider, Expression<Action<Action<TEventArgs>>> addHandler, Expression<Action<Action<TEventArgs>>> removeHandler, IScheduler scheduler)
1. Overload¶
public static IQbservable<Unit> FromEvent(this IQbservableProvider provider, Expression<Action<Action>> addHandler, Expression<Action<Action>> removeHandler)
Summary: Converts an Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
Parameters
| Name | Type | Description |
|---|---|---|
provider | [IQbservableProvider](# | Query provider used to construct the [IQbservable](# data source. |
addHandler | Expression | Action that attaches the given event handler to the underlying .NET event. |
removeHandler | Expression | Action that detaches the given event handler from the underlying .NET event. |
Returns: IQbservable
Remarks
Add and remove handler invocations are made whenever the number of observers grows beyond zero. As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
The current SynchronizationContext is captured during the call to FromEvent, and is used to post add and remove handler invocations. This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread making the Subscribe or Dispose call, respectively.
It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions more concise and easier to understand.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | addHandler or removeHandler is null. |
See also
2. Overload¶
public static IQbservable<Unit> FromEvent(this IQbservableProvider provider, Expression<Action<Action>> addHandler, Expression<Action<Action>> removeHandler, IScheduler scheduler)
Summary: Converts an Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
Parameters
| Name | Type | Description |
|---|---|---|
provider | [IQbservableProvider](# | Query provider used to construct the [IQbservable](# data source. |
addHandler | Expression | Action that attaches the given event handler to the underlying .NET event. |
removeHandler | Expression | Action that detaches the given event handler from the underlying .NET event. |
scheduler | [IScheduler](# | The scheduler to run the add and remove event handler logic on. |
Returns: IQbservable
Remarks
Add and remove handler invocations are made whenever the number of observers grows beyond zero. As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be accessed from the same context, as required by some UI frameworks.
It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries, making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler parameter. For more information, see the remarks section on those overloads.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | addHandler or removeHandler or scheduler is null. |
See also
3. Overload¶
public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
Summary: Converts a .NET event to an observable sequence, using a supplied event delegate type. Each event invocation is surfaced through an OnNext message in the resulting sequence. For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
Type parameters
| Name | Description |
|---|---|
TDelegate | The delegate type of the event to be converted. |
TEventArgs | The type of the event data generated by the event. |
Parameters
| Name | Type | Description |
|---|---|---|
provider | [IQbservableProvider](# | Query provider used to construct the [IQbservable](# data source. |
addHandler | Expression | Action that attaches the given event handler to the underlying .NET event. |
removeHandler | Expression | Action that detaches the given event handler from the underlying .NET event. |
Returns: IQbservable
Remarks
Add and remove handler invocations are made whenever the number of observers grows beyond zero. As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
The current SynchronizationContext is captured during the call to FromEvent, and is used to post add and remove handler invocations. This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread making the Subscribe or Dispose call, respectively.
It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions more concise and easier to understand.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | addHandler or removeHandler is null. |
See also
4. Overload¶
public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
Summary: Converts a .NET event to an observable sequence, using a supplied event delegate type. Each event invocation is surfaced through an OnNext message in the resulting sequence. For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
Type parameters
| Name | Description |
|---|---|
TDelegate | The delegate type of the event to be converted. |
TEventArgs | The type of the event data generated by the event. |
Parameters
| Name | Type | Description |
|---|---|---|
provider | [IQbservableProvider](# | Query provider used to construct the [IQbservable](# data source. |
addHandler | Expression | Action that attaches the given event handler to the underlying .NET event. |
removeHandler | Expression | Action that detaches the given event handler from the underlying .NET event. |
scheduler | [IScheduler](# | The scheduler to run the add and remove event handler logic on. |
Returns: IQbservable
Remarks
Add and remove handler invocations are made whenever the number of observers grows beyond zero. As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be accessed from the same context, as required by some UI frameworks.
It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries, making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler parameter. For more information, see the remarks section on those overloads.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | addHandler or removeHandler or scheduler is null. |
See also
5. Overload¶
public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<Action<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
Summary: Converts a .NET event to an observable sequence, using a conversion function to obtain the event delegate. Each event invocation is surfaced through an OnNext message in the resulting sequence. For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
Type parameters
| Name | Description |
|---|---|
TDelegate | The delegate type of the event to be converted. |
TEventArgs | The type of the event data generated by the event. |
Parameters
| Name | Type | Description |
|---|---|---|
provider | [IQbservableProvider](# | Query provider used to construct the [IQbservable](# data source. |
conversion | Expression | A function used to convert the given event handler to a delegate compatible with the underlying .NET event. The resulting delegate is used in calls to the addHandler and removeHandler action parameters. |
addHandler | Expression | Action that attaches the given event handler to the underlying .NET event. |
removeHandler | Expression | Action that detaches the given event handler from the underlying .NET event. |
Returns: IQbservable
Remarks
Add and remove handler invocations are made whenever the number of observers grows beyond zero. As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
The current SynchronizationContext is captured during the call to FromEvent, and is used to post add and remove handler invocations. This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread making the Subscribe or Dispose call, respectively.
It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions more concise and easier to understand.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | conversion or addHandler or removeHandler is null. |
See also
6. Overload¶
public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<Action<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
Summary: Converts a .NET event to an observable sequence, using a conversion function to obtain the event delegate. Each event invocation is surfaced through an OnNext message in the resulting sequence. For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
Type parameters
| Name | Description |
|---|---|
TDelegate | The delegate type of the event to be converted. |
TEventArgs | The type of the event data generated by the event. |
Parameters
| Name | Type | Description |
|---|---|---|
provider | [IQbservableProvider](# | Query provider used to construct the [IQbservable](# data source. |
conversion | Expression | A function used to convert the given event handler to a delegate compatible with the underlying .NET event. The resulting delegate is used in calls to the addHandler and removeHandler action parameters. |
addHandler | Expression | Action that attaches the given event handler to the underlying .NET event. |
removeHandler | Expression | Action that detaches the given event handler from the underlying .NET event. |
scheduler | [IScheduler](# | The scheduler to run the add and remove event handler logic on. |
Returns: IQbservable
Remarks
Add and remove handler invocations are made whenever the number of observers grows beyond zero. As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be accessed from the same context, as required by some UI frameworks.
It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries, making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler parameter. For more information, see the remarks section on those overloads.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | conversion or addHandler or removeHandler or scheduler is null. |
See also
7. Overload¶
public static IQbservable<TEventArgs> FromEvent<TEventArgs>(this IQbservableProvider provider, Expression<Action<Action<TEventArgs>>> addHandler, Expression<Action<Action<TEventArgs>>> removeHandler)
Summary: Converts a generic Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
Type parameters
| Name | Description |
|---|---|
TEventArgs | The type of the event data generated by the event. |
Parameters
| Name | Type | Description |
|---|---|---|
provider | [IQbservableProvider](# | Query provider used to construct the [IQbservable](# data source. |
addHandler | Expression | Action that attaches the given event handler to the underlying .NET event. |
removeHandler | Expression | Action that detaches the given event handler from the underlying .NET event. |
Returns: IQbservable
Remarks
Add and remove handler invocations are made whenever the number of observers grows beyond zero. As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
The current SynchronizationContext is captured during the call to FromEvent, and is used to post add and remove handler invocations. This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread making the Subscribe or Dispose call, respectively.
It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions more concise and easier to understand.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | addHandler or removeHandler is null. |
See also
8. Overload¶
public static IQbservable<TEventArgs> FromEvent<TEventArgs>(this IQbservableProvider provider, Expression<Action<Action<TEventArgs>>> addHandler, Expression<Action<Action<TEventArgs>>> removeHandler, IScheduler scheduler)
Summary: Converts a generic Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
Type parameters
| Name | Description |
|---|---|
TEventArgs | The type of the event data generated by the event. |
Parameters
| Name | Type | Description |
|---|---|---|
provider | [IQbservableProvider](# | Query provider used to construct the [IQbservable](# data source. |
addHandler | Expression | Action that attaches the given event handler to the underlying .NET event. |
removeHandler | Expression | Action that detaches the given event handler from the underlying .NET event. |
scheduler | [IScheduler](# | The scheduler to run the add and remove event handler logic on. |
Returns: IQbservable
Remarks
Add and remove handler invocations are made whenever the number of observers grows beyond zero. As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be accessed from the same context, as required by some UI frameworks.
It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries, making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler parameter. For more information, see the remarks section on those overloads.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | addHandler or removeHandler or scheduler is null. |
See also