Start.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the Apache 2.0 License.
  3. // See the LICENSE file in the project root for more information.
  4. using System.Reactive.Concurrency;
  5. namespace System.Reactive.Linq
  6. {
  7. partial class AsyncObservable
  8. {
  9. public static IAsyncObservable<TSource> Start<TSource>(Func<TSource> function)
  10. {
  11. if (function == null)
  12. throw new ArgumentNullException(nameof(function));
  13. return ToAsync(function)();
  14. }
  15. public static IAsyncObservable<TSource> Start<TSource>(Func<TSource> function, IAsyncScheduler scheduler)
  16. {
  17. if (function == null)
  18. throw new ArgumentNullException(nameof(function));
  19. if (scheduler == null)
  20. throw new ArgumentNullException(nameof(scheduler));
  21. return ToAsync(function, scheduler)();
  22. }
  23. public static IAsyncObservable<Unit> Start(Action action)
  24. {
  25. if (action == null)
  26. throw new ArgumentNullException(nameof(action));
  27. return ToAsync(action)();
  28. }
  29. public static IAsyncObservable<Unit> Start(Action action, IAsyncScheduler scheduler)
  30. {
  31. if (action == null)
  32. throw new ArgumentNullException(nameof(action));
  33. if (scheduler == null)
  34. throw new ArgumentNullException(nameof(scheduler));
  35. return ToAsync(action, scheduler)();
  36. }
  37. }
  38. }