File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
PowerSync/PowerSync.Common/Utils Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -53,16 +53,20 @@ public CancellationTokenSource RunListenerAsync(
5353 Func < T , Task > callback )
5454 {
5555 var cts = new CancellationTokenSource ( ) ;
56+ var started = new TaskCompletionSource < bool > ( ) ;
5657
5758 _ = Task . Run ( async ( ) =>
5859 {
60+ started . SetResult ( true ) ;
5961 await foreach ( var value in ListenAsync ( cts . Token ) )
6062 {
6163 await callback ( value ) ;
6264 }
6365
6466 } , cts . Token ) ;
6567
68+ started . Task . GetAwaiter ( ) . GetResult ( ) ;
69+
6670 return cts ;
6771 }
6872
@@ -76,15 +80,19 @@ public IAsyncEnumerable<T> ListenAsync(CancellationToken cancellationToken)
7680 public CancellationTokenSource RunListener ( Action < T > callback )
7781 {
7882 var cts = new CancellationTokenSource ( ) ;
83+ var started = new TaskCompletionSource < bool > ( ) ;
7984
8085 _ = Task . Run ( ( ) =>
8186 {
87+ started . SetResult ( true ) ;
8288 foreach ( var value in Listen ( cts . Token ) )
8389 {
8490 callback ( value ) ;
8591 }
8692 } , cts . Token ) ;
8793
94+ started . Task . GetAwaiter ( ) . GetResult ( ) ;
95+
8896 return cts ;
8997 }
9098
You can’t perform that action at this time.
0 commit comments