File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed
src/net45/WampSharp/WAMP2/V2/Api/Rx Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -78,10 +78,28 @@ public IDisposable Subscribe(IObserver<IWampSerializedEvent> observer)
78
78
{
79
79
Task < IDisposable > task = mTopic . Subscribe ( new RawTopicClientSubscriber ( observer ) , new SubscribeOptions ( ) ) ;
80
80
81
- // TODO: think of a better solution
82
- task . Wait ( ) ;
81
+ FutureDisposable result = new FutureDisposable ( task ) ;
83
82
84
- return task . Result ;
83
+ return result ;
84
+ }
85
+
86
+ private class FutureDisposable : IDisposable
87
+ {
88
+ private readonly Task < IDisposable > mDisposableTask ;
89
+
90
+ public FutureDisposable ( Task < IDisposable > disposableTask )
91
+ {
92
+ mDisposableTask = disposableTask ;
93
+ }
94
+
95
+ public void Dispose ( )
96
+ {
97
+ if ( mDisposableTask . IsCompleted )
98
+ {
99
+ IDisposable result = mDisposableTask . Result ;
100
+ result . Dispose ( ) ;
101
+ }
102
+ }
85
103
}
86
104
}
87
105
}
You can’t perform that action at this time.
0 commit comments