Skip to content

},System.Linq.Expressions.Expression{System.Action{System.EventHandler}})} },System.Linq.Expressions.Expression{System.Action{System.EventHandler}},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{--0}})} },System.Linq.Expressions.Expression{System.Action{--0}},System.Reactive.Concurrency.IScheduler)} }},System.Linq.Expressions.Expression{System.Action{System.EventHandler{--0}}})} }},System.Linq.Expressions.Expression{System.Action{System.EventHandler{--0}}},System.Reactive.Concurrency.IScheduler)}

Qbservable.FromEventPattern(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<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler)
  • 2. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler, IScheduler scheduler)
  • 3. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, object target, string eventName)
  • 4. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  • 5. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName)
  • 6. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  • 7. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  • 8. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  • 9. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<EventHandler<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  • 10. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<EventHandler<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  • 11. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  • 12. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  • 13. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Expression<Action<EventHandler<TEventArgs>>> addHandler, Expression<Action<EventHandler<TEventArgs>>> removeHandler)
  • 14. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Expression<Action<EventHandler<TEventArgs>>> addHandler, Expression<Action<EventHandler<TEventArgs>>> removeHandler, IScheduler scheduler)
  • 15. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, object target, string eventName)
  • 16. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  • 17. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Type type, string eventName)
  • 18. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  • 19. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, object target, string eventName)
  • 20. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  • 21. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, Type type, string eventName)
  • 22. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)

1. Overload

public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler)

Summary: Converts a .NET event, conforming to the standard .NET event pattern based on EventHandler, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
addHandlerExpression>Action that attaches the given event handler to the underlying .NET event.
removeHandlerExpression>Action that detaches the given event handler from the underlying .NET event.

Returns: IQbservable> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern, 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 FromEventPattern, add and remove handler invocations are made synchronously on the thread making the Subscribe or Dispose call, respectively.

It's recommended to lift FromEventPattern 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

TypeCondition
System.ArgumentNullExceptionaddHandler or removeHandler is null.

See also

2. Overload

public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler, IScheduler scheduler)

Summary: Converts a .NET event, conforming to the standard .NET event pattern based on EventHandler, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
addHandlerExpression>Action that attaches the given event handler to the underlying .NET event.
removeHandlerExpression>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> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern 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 FromEventPattern that omit the IScheduler parameter. For more information, see the remarks section on those overloads.

Exceptions

TypeCondition
System.ArgumentNullExceptionaddHandler or removeHandler or scheduler is null.

See also

3. Overload

public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, object target, string eventName)

Summary: Converts an instance .NET event, conforming to the standard .NET event pattern with an EventArgs parameter, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. Reflection is used to discover the event based on the target object type and the specified event name. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
targetobjectObject instance that exposes the event to convert.
eventNamestringName of the event to convert.

Returns: IQbservable> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern, 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 FromEventPattern, add and remove handler invocations are made synchronously on the thread making the Subscribe or Dispose call, respectively.

It's recommended to lift FromEventPattern 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

TypeCondition
System.ArgumentNullExceptiontarget or eventName is null.
System.InvalidOperationExceptionThe event could not be found. -or- The event does not conform to the standard .NET event pattern.

See also

4. Overload

public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)

Summary: Converts an instance .NET event, conforming to the standard .NET event pattern with an EventArgs parameter, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. Reflection is used to discover the event based on the target object type and the specified event name. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
targetobjectObject instance that exposes the event to convert.
eventNamestringName of the event to convert.
scheduler[IScheduler](#The scheduler to run the add and remove event handler logic on.

Returns: IQbservable> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern 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 FromEventPattern that omit the IScheduler parameter. For more information, see the remarks section on those overloads.

Exceptions

TypeCondition
System.ArgumentNullExceptiontarget or eventName or scheduler is null.
System.InvalidOperationExceptionThe event could not be found. -or- The event does not conform to the standard .NET event pattern.

See also

5. Overload

public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName)

Summary: Converts a static .NET event, conforming to the standard .NET event pattern with an EventArgs parameter, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. Reflection is used to discover the event based on the specified type and the specified event name. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
typeTypeType that exposes the static event to convert.
eventNamestringName of the event to convert.

Returns: IQbservable> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern, 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 FromEventPattern, add and remove handler invocations are made synchronously on the thread making the Subscribe or Dispose call, respectively.

It's recommended to lift FromEventPattern 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

TypeCondition
System.ArgumentNullExceptiontype or eventName is null.
System.InvalidOperationExceptionThe event could not be found. -or- The event does not conform to the standard .NET event pattern.

See also

6. Overload

public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)

Summary: Converts a static .NET event, conforming to the standard .NET event pattern with an EventArgs parameter, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. Reflection is used to discover the event based on the specified type and the specified event name. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
typeTypeType that exposes the static event to convert.
eventNamestringName of the event to convert.
scheduler[IScheduler](#The scheduler to run the add and remove event handler logic on.

Returns: IQbservable> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern 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 FromEventPattern that omit the IScheduler parameter. For more information, see the remarks section on those overloads.

Exceptions

TypeCondition
System.ArgumentNullExceptiontype or eventName or scheduler is null.
System.InvalidOperationExceptionThe event could not be found. -or- The event does not conform to the standard .NET event pattern.

See also

7. Overload

public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)

Summary: Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Type parameters

NameDescription
TDelegateThe delegate type of the event to be converted.
TEventArgsThe type of the event data generated by the event.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
addHandlerExpression>Action that attaches the given event handler to the underlying .NET event.
removeHandlerExpression>Action that detaches the given event handler from the underlying .NET event.

Returns: IQbservable> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern, 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 FromEventPattern, add and remove handler invocations are made synchronously on the thread making the Subscribe or Dispose call, respectively.

It's recommended to lift FromEventPattern 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

TypeCondition
System.ArgumentNullExceptionaddHandler or removeHandler is null.

See also

8. Overload

public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)

Summary: Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Type parameters

NameDescription
TDelegateThe delegate type of the event to be converted.
TEventArgsThe type of the event data generated by the event.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
addHandlerExpression>Action that attaches the given event handler to the underlying .NET event.
removeHandlerExpression>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> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern 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 FromEventPattern that omit the IScheduler parameter. For more information, see the remarks section on those overloads.

Exceptions

TypeCondition
System.ArgumentNullExceptionaddHandler or removeHandler or scheduler is null.

See also

9. Overload

public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<EventHandler<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)

Summary: Converts a .NET event, conforming to the standard .NET event pattern based on EventHandler, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Type parameters

NameDescription
TDelegateThe delegate type of the event to be converted.
TEventArgsThe type of the event data generated by the event.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
conversionExpression, TDelegate>>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.
addHandlerExpression>Action that attaches the given event handler to the underlying .NET event.
removeHandlerExpression>Action that detaches the given event handler from the underlying .NET event.

Returns: IQbservable> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern, 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 FromEventPattern, add and remove handler invocations are made synchronously on the thread making the Subscribe or Dispose call, respectively.

It's recommended to lift FromEventPattern 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

TypeCondition
System.ArgumentNullExceptionconversion or addHandler or removeHandler is null.

See also

10. Overload

public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<EventHandler<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)

Summary: Converts a .NET event, conforming to the standard .NET event pattern based on EventHandler, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Type parameters

NameDescription
TDelegateThe delegate type of the event to be converted.
TEventArgsThe type of the event data generated by the event.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
conversionExpression, TDelegate>>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.
addHandlerExpression>Action that attaches the given event handler to the underlying .NET event.
removeHandlerExpression>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> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern 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 FromEventPattern that omit the IScheduler parameter. For more information, see the remarks section on those overloads.

Exceptions

TypeCondition
System.ArgumentNullExceptionconversion or addHandler or removeHandler or scheduler is null.

See also

11. Overload

public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)

Summary: Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type with a strongly typed sender parameter, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Type parameters

NameDescription
TDelegateThe delegate type of the event to be converted.
TSenderThe type of the sender that raises the event.
TEventArgsThe type of the event data generated by the event.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
addHandlerExpression>Action that attaches the given event handler to the underlying .NET event.
removeHandlerExpression>Action that detaches the given event handler from the underlying .NET event.

Returns: IQbservable> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern, 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 FromEventPattern, add and remove handler invocations are made synchronously on the thread making the Subscribe or Dispose call, respectively.

It's recommended to lift FromEventPattern 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

TypeCondition
System.ArgumentNullExceptionaddHandler or removeHandler is null.

See also

12. Overload

public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)

Summary: Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type with a strongly typed sender parameter, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Type parameters

NameDescription
TDelegateThe delegate type of the event to be converted.
TSenderThe type of the sender that raises the event.
TEventArgsThe type of the event data generated by the event.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
addHandlerExpression>Action that attaches the given event handler to the underlying .NET event.
removeHandlerExpression>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> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern 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 FromEventPattern that omit the IScheduler parameter. For more information, see the remarks section on those overloads.

Exceptions

TypeCondition
System.ArgumentNullExceptionaddHandler or removeHandler or scheduler is null.

See also

13. Overload

public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Expression<Action<EventHandler<TEventArgs>>> addHandler, Expression<Action<EventHandler<TEventArgs>>> removeHandler)

Summary: Converts a .NET event, conforming to the standard .NET event pattern based on EventHandler, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Type parameters

NameDescription
TEventArgsThe type of the event data generated by the event.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
addHandlerExpression>>Action that attaches the given event handler to the underlying .NET event.
removeHandlerExpression>>Action that detaches the given event handler from the underlying .NET event.

Returns: IQbservable> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern, 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 FromEventPattern, add and remove handler invocations are made synchronously on the thread making the Subscribe or Dispose call, respectively.

It's recommended to lift FromEventPattern 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.

See also

14. Overload

public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Expression<Action<EventHandler<TEventArgs>>> addHandler, Expression<Action<EventHandler<TEventArgs>>> removeHandler, IScheduler scheduler)

Summary: Converts a .NET event, conforming to the standard .NET event pattern based on EventHandler, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Type parameters

NameDescription
TEventArgsThe type of the event data generated by the event.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
addHandlerExpression>>Action that attaches the given event handler to the underlying .NET event.
removeHandlerExpression>>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> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern 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 FromEventPattern that omit the IScheduler parameter. For more information, see the remarks section on those overloads.

See also

15. Overload

public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, object target, string eventName)

Summary: Converts an instance .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. Reflection is used to discover the event based on the target object type and the specified event name. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Type parameters

NameDescription
TEventArgsThe type of the event data generated by the event.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
targetobjectObject instance that exposes the event to convert.
eventNamestringName of the event to convert.

Returns: IQbservable> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern, 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 FromEventPattern, add and remove handler invocations are made synchronously on the thread making the Subscribe or Dispose call, respectively.

It's recommended to lift FromEventPattern 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

TypeCondition
System.ArgumentNullExceptiontarget or eventName is null.
System.InvalidOperationExceptionThe event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's second argument type is not assignable to TEventArgs.

See also

16. Overload

public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)

Summary: Converts an instance .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. Reflection is used to discover the event based on the target object type and the specified event name. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Type parameters

NameDescription
TEventArgsThe type of the event data generated by the event.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
targetobjectObject instance that exposes the event to convert.
eventNamestringName of the event to convert.
scheduler[IScheduler](#The scheduler to run the add and remove event handler logic on.

Returns: IQbservable> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern 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 FromEventPattern that omit the IScheduler parameter. For more information, see the remarks section on those overloads.

Exceptions

TypeCondition
System.ArgumentNullExceptiontarget or eventName or scheduler is null.
System.InvalidOperationExceptionThe event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's second argument type is not assignable to TEventArgs.

See also

17. Overload

public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Type type, string eventName)

Summary: Converts a static .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. Reflection is used to discover the event based on the specified type and the specified event name. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Type parameters

NameDescription
TEventArgsThe type of the event data generated by the event.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
typeTypeType that exposes the static event to convert.
eventNamestringName of the event to convert.

Returns: IQbservable> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern, 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 FromEventPattern, add and remove handler invocations are made synchronously on the thread making the Subscribe or Dispose call, respectively.

It's recommended to lift FromEventPattern 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

TypeCondition
System.ArgumentNullExceptiontype or eventName is null.
System.InvalidOperationExceptionThe event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's second argument type is not assignable to TEventArgs.

See also

18. Overload

public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)

Summary: Converts a static .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. Reflection is used to discover the event based on the specified type and the specified event name. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Type parameters

NameDescription
TEventArgsThe type of the event data generated by the event.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
typeTypeType that exposes the static event to convert.
eventNamestringName of the event to convert.
scheduler[IScheduler](#The scheduler to run the add and remove event handler logic on.

Returns: IQbservable> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern 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 FromEventPattern that omit the IScheduler parameter. For more information, see the remarks section on those overloads.

Exceptions

TypeCondition
System.ArgumentNullExceptiontype or eventName or scheduler is null.
System.InvalidOperationExceptionThe event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's second argument type is not assignable to TEventArgs.

See also

19. Overload

public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, object target, string eventName)

Summary: Converts an instance .NET event, conforming to the standard .NET event pattern with a strongly typed sender and strongly typed event arguments, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. Reflection is used to discover the event based on the target object type and the specified event name. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Type parameters

NameDescription
TSenderThe type of the sender that raises the event.
TEventArgsThe type of the event data generated by the event.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
targetobjectObject instance that exposes the event to convert.
eventNamestringName of the event to convert.

Returns: IQbservable> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern, 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 FromEventPattern, add and remove handler invocations are made synchronously on the thread making the Subscribe or Dispose call, respectively.

It's recommended to lift FromEventPattern 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

TypeCondition
System.ArgumentNullExceptiontarget or eventName is null.
System.InvalidOperationExceptionThe event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's first argument type is not assignable to TSender. -or- The event's second argument type is not assignable to TEventArgs.

See also

20. Overload

public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)

Summary: Converts an instance .NET event, conforming to the standard .NET event pattern with a strongly typed sender and strongly typed event arguments, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. Reflection is used to discover the event based on the target object type and the specified event name. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Type parameters

NameDescription
TSenderThe type of the sender that raises the event.
TEventArgsThe type of the event data generated by the event.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
targetobjectObject instance that exposes the event to convert.
eventNamestringName of the event to convert.
scheduler[IScheduler](#The scheduler to run the add and remove event handler logic on.

Returns: IQbservable> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern 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 FromEventPattern that omit the IScheduler parameter. For more information, see the remarks section on those overloads.

Exceptions

TypeCondition
System.ArgumentNullExceptiontarget or eventName or scheduler is null.
System.InvalidOperationExceptionThe event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's first argument type is not assignable to TSender. -or- The event's second argument type is not assignable to TEventArgs.

See also

21. Overload

public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, Type type, string eventName)

Summary: Converts a static .NET event, conforming to the standard .NET event pattern with a strongly typed sender and strongly typed event arguments, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. Reflection is used to discover the event based on the specified type and the specified event name. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Type parameters

NameDescription
TSenderThe type of the sender that raises the event.
TEventArgsThe type of the event data generated by the event.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
typeTypeType that exposes the static event to convert.
eventNamestringName of the event to convert.

Returns: IQbservable> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern, 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 FromEventPattern, add and remove handler invocations are made synchronously on the thread making the Subscribe or Dispose call, respectively.

It's recommended to lift FromEventPattern 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

TypeCondition
System.ArgumentNullExceptiontype or eventName is null.
System.InvalidOperationExceptionThe event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's first argument type is not assignable to TSender. -or- The event's second argument type is not assignable to TEventArgs.

See also

22. Overload

public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)

Summary: Converts a static .NET event, conforming to the standard .NET event pattern with a strongly typed sender and strongly typed event arguments, to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. Reflection is used to discover the event based on the specified type and the specified event name. For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.

Type parameters

NameDescription
TSenderThe type of the sender that raises the event.
TEventArgsThe type of the event data generated by the event.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
typeTypeType that exposes the static event to convert.
eventNamestringName of the event to convert.
scheduler[IScheduler](#The scheduler to run the add and remove event handler logic on.

Returns: IQbservable> -- The observable sequence that contains data representations of invocations of the underlying .NET event.

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 FromEventPattern 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 FromEventPattern that omit the IScheduler parameter. For more information, see the remarks section on those overloads.

Exceptions

TypeCondition
System.ArgumentNullExceptiontype or eventName or scheduler is null.
System.InvalidOperationExceptionThe event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's first argument type is not assignable to TSender. -or- The event's second argument type is not assignable to TEventArgs.

See also