Interval.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. using System.Threading.Tasks;
  6. namespace System.Reactive.Linq
  7. {
  8. partial class AsyncObservable
  9. {
  10. public static IAsyncObservable<long> Interval(TimeSpan period)
  11. {
  12. if (period < TimeSpan.Zero)
  13. throw new ArgumentOutOfRangeException(nameof(period));
  14. return Create<long>(observer => AsyncObserver.Interval(observer, period));
  15. }
  16. public static IAsyncObservable<long> Interval(TimeSpan period, IAsyncScheduler scheduler)
  17. {
  18. if (period < TimeSpan.Zero)
  19. throw new ArgumentOutOfRangeException(nameof(period));
  20. if (scheduler == null)
  21. throw new ArgumentNullException(nameof(scheduler));
  22. return Create<long>(observer => AsyncObserver.Interval(observer, period, scheduler));
  23. }
  24. }
  25. partial class AsyncObserver
  26. {
  27. public static Task<IAsyncDisposable> Interval(IAsyncObserver<long> observer, TimeSpan period)
  28. {
  29. if (observer == null)
  30. throw new ArgumentNullException(nameof(observer));
  31. if (period < TimeSpan.Zero)
  32. throw new ArgumentOutOfRangeException(nameof(period));
  33. throw new NotImplementedException();
  34. }
  35. public static Task<IAsyncDisposable> Interval(IAsyncObserver<long> observer, TimeSpan period, IAsyncScheduler scheduler)
  36. {
  37. if (observer == null)
  38. throw new ArgumentNullException(nameof(observer));
  39. if (period < TimeSpan.Zero)
  40. throw new ArgumentOutOfRangeException(nameof(period));
  41. if (scheduler == null)
  42. throw new ArgumentNullException(nameof(scheduler));
  43. throw new NotImplementedException();
  44. }
  45. }
  46. }