Debian Codegraph @

external/rx/Rx/NET/Source/System.Reactive.Linq/Reactive/Linq/Observable/Throw.cs

raw
1 // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2
3 #if !NO_PERF
4 using System;
5 using System.Reactive.Concurrency;
6
7 namespace System.Reactive.Linq.ObservableImpl
8 {
9 class Throw<TResult> : Producer<TResult>
10 {
11 private readonly Exception _exception;
12 private readonly IScheduler _scheduler;
13
14 public Throw(Exception exception, IScheduler scheduler)
15 {
16 _exception = exception;
17 _scheduler = scheduler;
18 }
19
20 protected override IDisposable Run(IObserver<TResult> observer, IDisposable cancel, Action<IDisposable> setSink)
21 {
22 var sink = new _(this, observer, cancel);
23 setSink(sink);
24 return sink.Run();
25 }
26
27 class _ : Sink<TResult>
28 {
29 private readonly Throw<TResult> _parent;
30
31 public _(Throw<TResult> parent, IObserver<TResult> observer, IDisposable cancel)
32 : base(observer, cancel)
33 {
34 _parent = parent;
35 }
36
37 public IDisposable Run()
38 {
39 return _parent._scheduler.Schedule(Invoke);
40 }
41
42 private void Invoke()
43 {
44 base._observer.OnError(_parent._exception);
45 base.Dispose();
46 }
47 }
48 }
49 }
50 #endif