// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. using System.Reactive.Concurrency; namespace System.Reactive.Linq { public static partial class Observable { #region + FromEventPattern + #region Strongly typed #region Action /// /// Converts a .NET event, conforming to the standard .NET event pattern based on , 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. /// /// Action that attaches the given event handler to the underlying .NET event. /// Action that detaches the given event handler from the underlying .NET event. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or is null. /// /// /// 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 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. /// /// /// public static IObservable> FromEventPattern(Action addHandler, Action removeHandler) { if (addHandler == null) { throw new ArgumentNullException(nameof(addHandler)); } if (removeHandler == null) { throw new ArgumentNullException(nameof(removeHandler)); } return s_impl.FromEventPattern(addHandler, removeHandler); } /// /// Converts a .NET event, conforming to the standard .NET event pattern based on , 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. /// /// Action that attaches the given event handler to the underlying .NET event. /// Action that detaches the given event handler from the underlying .NET event. /// The scheduler to run the add and remove event handler logic on. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or or is null. /// /// /// 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. /// /// /// public static IObservable> FromEventPattern(Action addHandler, Action removeHandler, IScheduler scheduler) { if (addHandler == null) { throw new ArgumentNullException(nameof(addHandler)); } if (removeHandler == null) { throw new ArgumentNullException(nameof(removeHandler)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } return s_impl.FromEventPattern(addHandler, removeHandler, scheduler); } #endregion #region Action /// /// 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. /// /// The delegate type of the event to be converted. /// The type of the event data generated by the event. /// Action that attaches the given event handler to the underlying .NET event. /// Action that detaches the given event handler from the underlying .NET event. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or is null. /// /// /// 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 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. /// /// /// public static IObservable> FromEventPattern(Action addHandler, Action removeHandler) { if (addHandler == null) { throw new ArgumentNullException(nameof(addHandler)); } if (removeHandler == null) { throw new ArgumentNullException(nameof(removeHandler)); } return s_impl.FromEventPattern(addHandler, removeHandler); } /// /// 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. /// /// The delegate type of the event to be converted. /// The type of the event data generated by the event. /// Action that attaches the given event handler to the underlying .NET event. /// Action that detaches the given event handler from the underlying .NET event. /// The scheduler to run the add and remove event handler logic on. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or or is null. /// /// /// 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. /// /// /// public static IObservable> FromEventPattern(Action addHandler, Action removeHandler, IScheduler scheduler) { if (addHandler == null) { throw new ArgumentNullException(nameof(addHandler)); } if (removeHandler == null) { throw new ArgumentNullException(nameof(removeHandler)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } return s_impl.FromEventPattern(addHandler, removeHandler, scheduler); } /// /// Converts a .NET event, conforming to the standard .NET event pattern based on , 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. /// /// The delegate type of the event to be converted. /// The type of the event data generated by the event. /// 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. /// Action that attaches the given event handler to the underlying .NET event. /// Action that detaches the given event handler from the underlying .NET event. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or or is null. /// /// /// 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 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. /// /// /// public static IObservable> FromEventPattern(Func, TDelegate> conversion, Action addHandler, Action removeHandler) { if (conversion == null) { throw new ArgumentNullException(nameof(conversion)); } if (addHandler == null) { throw new ArgumentNullException(nameof(addHandler)); } if (removeHandler == null) { throw new ArgumentNullException(nameof(removeHandler)); } return s_impl.FromEventPattern(conversion, addHandler, removeHandler); } /// /// Converts a .NET event, conforming to the standard .NET event pattern based on , 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. /// /// The delegate type of the event to be converted. /// The type of the event data generated by the event. /// 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. /// Action that attaches the given event handler to the underlying .NET event. /// Action that detaches the given event handler from the underlying .NET event. /// The scheduler to run the add and remove event handler logic on. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or or or is null. /// /// /// 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. /// /// /// public static IObservable> FromEventPattern(Func, TDelegate> conversion, Action addHandler, Action removeHandler, IScheduler scheduler) { if (conversion == null) { throw new ArgumentNullException(nameof(conversion)); } if (addHandler == null) { throw new ArgumentNullException(nameof(addHandler)); } if (removeHandler == null) { throw new ArgumentNullException(nameof(removeHandler)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } return s_impl.FromEventPattern(conversion, addHandler, removeHandler, scheduler); } /// /// 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. /// /// The delegate type of the event to be converted. /// The type of the sender that raises the event. /// The type of the event data generated by the event. /// Action that attaches the given event handler to the underlying .NET event. /// Action that detaches the given event handler from the underlying .NET event. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or is null. /// /// /// 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 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. /// /// /// public static IObservable> FromEventPattern(Action addHandler, Action removeHandler) { if (addHandler == null) { throw new ArgumentNullException(nameof(addHandler)); } if (removeHandler == null) { throw new ArgumentNullException(nameof(removeHandler)); } return s_impl.FromEventPattern(addHandler, removeHandler); } /// /// 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. /// /// The delegate type of the event to be converted. /// The type of the sender that raises the event. /// The type of the event data generated by the event. /// Action that attaches the given event handler to the underlying .NET event. /// Action that detaches the given event handler from the underlying .NET event. /// The scheduler to run the add and remove event handler logic on. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or or is null. /// /// /// 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. /// /// /// public static IObservable> FromEventPattern(Action addHandler, Action removeHandler, IScheduler scheduler) { if (addHandler == null) { throw new ArgumentNullException(nameof(addHandler)); } if (removeHandler == null) { throw new ArgumentNullException(nameof(removeHandler)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } return s_impl.FromEventPattern(addHandler, removeHandler, scheduler); } #endregion #region Action> /// /// Converts a .NET event, conforming to the standard .NET event pattern based on , 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. /// /// The type of the event data generated by the event. /// Action that attaches the given event handler to the underlying .NET event. /// Action that detaches the given event handler from the underlying .NET event. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// /// /// 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 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. /// /// /// public static IObservable> FromEventPattern(Action> addHandler, Action> removeHandler) { if (addHandler == null) { throw new ArgumentNullException(nameof(addHandler)); } if (removeHandler == null) { throw new ArgumentNullException(nameof(removeHandler)); } return s_impl.FromEventPattern(addHandler, removeHandler); } /// /// Converts a .NET event, conforming to the standard .NET event pattern based on , 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. /// /// The type of the event data generated by the event. /// Action that attaches the given event handler to the underlying .NET event. /// Action that detaches the given event handler from the underlying .NET event. /// The scheduler to run the add and remove event handler logic on. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// /// /// 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. /// /// /// public static IObservable> FromEventPattern(Action> addHandler, Action> removeHandler, IScheduler scheduler) { if (addHandler == null) { throw new ArgumentNullException(nameof(addHandler)); } if (removeHandler == null) { throw new ArgumentNullException(nameof(removeHandler)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } return s_impl.FromEventPattern(addHandler, removeHandler, scheduler); } #endregion #endregion #region Reflection #region Instance events /// /// Converts an instance .NET event, conforming to the standard .NET event pattern with an 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. /// /// Object instance that exposes the event to convert. /// Name of the event to convert. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or is null. /// The event could not be found. -or- The event does not conform to the standard .NET event pattern. /// /// /// 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 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. /// /// /// public static IObservable> FromEventPattern(object target, string eventName) { if (target == null) { throw new ArgumentNullException(nameof(target)); } if (eventName == null) { throw new ArgumentNullException(nameof(eventName)); } return s_impl.FromEventPattern(target, eventName); } /// /// Converts an instance .NET event, conforming to the standard .NET event pattern with an 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. /// /// Object instance that exposes the event to convert. /// Name of the event to convert. /// The scheduler to run the add and remove event handler logic on. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or or is null. /// The event could not be found. -or- The event does not conform to the standard .NET event pattern. /// /// /// 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. /// /// /// public static IObservable> FromEventPattern(object target, string eventName, IScheduler scheduler) { if (target == null) { throw new ArgumentNullException(nameof(target)); } if (eventName == null) { throw new ArgumentNullException(nameof(eventName)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } return s_impl.FromEventPattern(target, eventName, scheduler); } /// /// 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. /// /// The type of the event data generated by the event. /// Object instance that exposes the event to convert. /// Name of the event to convert. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or is null. /// The 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. /// /// /// 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 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. /// /// /// public static IObservable> FromEventPattern(object target, string eventName) { if (target == null) { throw new ArgumentNullException(nameof(target)); } if (eventName == null) { throw new ArgumentNullException(nameof(eventName)); } return s_impl.FromEventPattern(target, eventName); } /// /// 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. /// /// The type of the event data generated by the event. /// Object instance that exposes the event to convert. /// Name of the event to convert. /// The scheduler to run the add and remove event handler logic on. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or or is null. /// The 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. /// /// /// 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. /// /// /// public static IObservable> FromEventPattern(object target, string eventName, IScheduler scheduler) { if (target == null) { throw new ArgumentNullException(nameof(target)); } if (eventName == null) { throw new ArgumentNullException(nameof(eventName)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } return s_impl.FromEventPattern(target, eventName, scheduler); } /// /// 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. /// /// The type of the sender that raises the event. /// The type of the event data generated by the event. /// Object instance that exposes the event to convert. /// Name of the event to convert. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or is null. /// The 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. /// /// /// 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 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. /// /// /// public static IObservable> FromEventPattern(object target, string eventName) { if (target == null) { throw new ArgumentNullException(nameof(target)); } if (eventName == null) { throw new ArgumentNullException(nameof(eventName)); } return s_impl.FromEventPattern(target, eventName); } /// /// 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. /// /// The type of the sender that raises the event. /// The type of the event data generated by the event. /// Object instance that exposes the event to convert. /// Name of the event to convert. /// The scheduler to run the add and remove event handler logic on. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or or is null. /// The 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. /// /// /// 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. /// /// /// public static IObservable> FromEventPattern(object target, string eventName, IScheduler scheduler) { if (target == null) { throw new ArgumentNullException(nameof(target)); } if (eventName == null) { throw new ArgumentNullException(nameof(eventName)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } return s_impl.FromEventPattern(target, eventName, scheduler); } #endregion #region Static events /// /// Converts a static .NET event, conforming to the standard .NET event pattern with an 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. /// /// Type that exposes the static event to convert. /// Name of the event to convert. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or is null. /// The event could not be found. -or- The event does not conform to the standard .NET event pattern. /// /// /// 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 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. /// /// /// public static IObservable> FromEventPattern(Type type, string eventName) { if (type == null) { throw new ArgumentNullException(nameof(type)); } if (eventName == null) { throw new ArgumentNullException(nameof(eventName)); } return s_impl.FromEventPattern(type, eventName); } /// /// Converts a static .NET event, conforming to the standard .NET event pattern with an 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. /// /// Type that exposes the static event to convert. /// Name of the event to convert. /// The scheduler to run the add and remove event handler logic on. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or or is null. /// The event could not be found. -or- The event does not conform to the standard .NET event pattern. /// /// /// 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. /// /// /// public static IObservable> FromEventPattern(Type type, string eventName, IScheduler scheduler) { if (type == null) { throw new ArgumentNullException(nameof(type)); } if (eventName == null) { throw new ArgumentNullException(nameof(eventName)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } return s_impl.FromEventPattern(type, eventName, scheduler); } /// /// 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. /// /// The type of the event data generated by the event. /// Type that exposes the static event to convert. /// Name of the event to convert. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or is null. /// The 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. /// /// /// 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 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. /// /// /// public static IObservable> FromEventPattern(Type type, string eventName) { if (type == null) { throw new ArgumentNullException(nameof(type)); } if (eventName == null) { throw new ArgumentNullException(nameof(eventName)); } return s_impl.FromEventPattern(type, eventName); } /// /// 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. /// /// The type of the event data generated by the event. /// Type that exposes the static event to convert. /// Name of the event to convert. /// The scheduler to run the add and remove event handler logic on. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or or is null. /// The 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. /// /// /// 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. /// /// /// public static IObservable> FromEventPattern(Type type, string eventName, IScheduler scheduler) { if (type == null) { throw new ArgumentNullException(nameof(type)); } if (eventName == null) { throw new ArgumentNullException(nameof(eventName)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } return s_impl.FromEventPattern(type, eventName, scheduler); } /// /// 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. /// /// The type of the sender that raises the event. /// The type of the event data generated by the event. /// Type that exposes the static event to convert. /// Name of the event to convert. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or is null. /// The 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. /// /// /// 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 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. /// /// /// public static IObservable> FromEventPattern(Type type, string eventName) { if (type == null) { throw new ArgumentNullException(nameof(type)); } if (eventName == null) { throw new ArgumentNullException(nameof(eventName)); } return s_impl.FromEventPattern(type, eventName); } /// /// 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. /// /// The type of the sender that raises the event. /// The type of the event data generated by the event. /// Type that exposes the static event to convert. /// Name of the event to convert. /// The scheduler to run the add and remove event handler logic on. /// The observable sequence that contains data representations of invocations of the underlying .NET event. /// or or is null. /// The 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. /// /// /// 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. /// /// /// public static IObservable> FromEventPattern(Type type, string eventName, IScheduler scheduler) { if (type == null) { throw new ArgumentNullException(nameof(type)); } if (eventName == null) { throw new ArgumentNullException(nameof(eventName)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } return s_impl.FromEventPattern(type, eventName, scheduler); } #endregion #endregion #endregion #region + FromEvent + #region Action /// /// 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. /// /// The delegate type of the event to be converted. /// The type of the event data generated by the event. /// 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. /// Action that attaches the given event handler to the underlying .NET event. /// Action that detaches the given event handler from the underlying .NET event. /// The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event. /// or or is null. /// /// /// 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 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. /// /// /// public static IObservable FromEvent(Func, TDelegate> conversion, Action addHandler, Action removeHandler) { if (conversion == null) { throw new ArgumentNullException(nameof(conversion)); } if (addHandler == null) { throw new ArgumentNullException(nameof(addHandler)); } if (removeHandler == null) { throw new ArgumentNullException(nameof(removeHandler)); } return s_impl.FromEvent(conversion, addHandler, removeHandler); } /// /// 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. /// /// The delegate type of the event to be converted. /// The type of the event data generated by the event. /// 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. /// Action that attaches the given event handler to the underlying .NET event. /// Action that detaches the given event handler from the underlying .NET event. /// The scheduler to run the add and remove event handler logic on. /// The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event. /// or or or is null. /// /// /// 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. /// /// /// public static IObservable FromEvent(Func, TDelegate> conversion, Action addHandler, Action removeHandler, IScheduler scheduler) { if (conversion == null) { throw new ArgumentNullException(nameof(conversion)); } if (addHandler == null) { throw new ArgumentNullException(nameof(addHandler)); } if (removeHandler == null) { throw new ArgumentNullException(nameof(removeHandler)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } return s_impl.FromEvent(conversion, addHandler, removeHandler, scheduler); } /// /// 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. /// /// The delegate type of the event to be converted. /// The type of the event data generated by the event. /// Action that attaches the given event handler to the underlying .NET event. /// Action that detaches the given event handler from the underlying .NET event. /// The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event. /// or is null. /// /// /// 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 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. /// /// /// public static IObservable FromEvent(Action addHandler, Action removeHandler) { if (addHandler == null) { throw new ArgumentNullException(nameof(addHandler)); } if (removeHandler == null) { throw new ArgumentNullException(nameof(removeHandler)); } return s_impl.FromEvent(addHandler, removeHandler); } /// /// 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. /// /// The delegate type of the event to be converted. /// The type of the event data generated by the event. /// Action that attaches the given event handler to the underlying .NET event. /// Action that detaches the given event handler from the underlying .NET event. /// The scheduler to run the add and remove event handler logic on. /// The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event. /// or or is null. /// /// /// 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. /// /// /// public static IObservable FromEvent(Action addHandler, Action removeHandler, IScheduler scheduler) { if (addHandler == null) { throw new ArgumentNullException(nameof(addHandler)); } if (removeHandler == null) { throw new ArgumentNullException(nameof(removeHandler)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } return s_impl.FromEvent(addHandler, removeHandler, scheduler); } #endregion #region Action> /// /// 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. /// /// The type of the event data generated by the event. /// Action that attaches the given event handler to the underlying .NET event. /// Action that detaches the given event handler from the underlying .NET event. /// The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event. /// or is null. /// /// /// 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 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. /// /// /// public static IObservable FromEvent(Action> addHandler, Action> removeHandler) { if (addHandler == null) { throw new ArgumentNullException(nameof(addHandler)); } if (removeHandler == null) { throw new ArgumentNullException(nameof(removeHandler)); } return s_impl.FromEvent(addHandler, removeHandler); } /// /// 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. /// /// The type of the event data generated by the event. /// Action that attaches the given event handler to the underlying .NET event. /// Action that detaches the given event handler from the underlying .NET event. /// The scheduler to run the add and remove event handler logic on. /// The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event. /// or or is null. /// /// /// 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. /// /// /// public static IObservable FromEvent(Action> addHandler, Action> removeHandler, IScheduler scheduler) { if (addHandler == null) { throw new ArgumentNullException(nameof(addHandler)); } if (removeHandler == null) { throw new ArgumentNullException(nameof(removeHandler)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } return s_impl.FromEvent(addHandler, removeHandler, scheduler); } #endregion #region Action /// /// 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. /// /// Action that attaches the given event handler to the underlying .NET event. /// Action that detaches the given event handler from the underlying .NET event. /// The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event. /// or is null. /// /// /// 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 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. /// /// /// public static IObservable FromEvent(Action addHandler, Action removeHandler) { if (addHandler == null) { throw new ArgumentNullException(nameof(addHandler)); } if (removeHandler == null) { throw new ArgumentNullException(nameof(removeHandler)); } return s_impl.FromEvent(addHandler, removeHandler); } /// /// 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. /// /// Action that attaches the given event handler to the underlying .NET event. /// Action that detaches the given event handler from the underlying .NET event. /// The scheduler to run the add and remove event handler logic on. /// The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event. /// or or is null. /// /// /// 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. /// /// /// public static IObservable FromEvent(Action addHandler, Action removeHandler, IScheduler scheduler) { if (addHandler == null) { throw new ArgumentNullException(nameof(addHandler)); } if (removeHandler == null) { throw new ArgumentNullException(nameof(removeHandler)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } return s_impl.FromEvent(addHandler, removeHandler, scheduler); } #endregion #endregion } }