File tree 1 file changed +8
-0
lines changed
PowerSync/PowerSync.Common/Utils
1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -53,16 +53,20 @@ public CancellationTokenSource RunListenerAsync(
53
53
Func < T , Task > callback )
54
54
{
55
55
var cts = new CancellationTokenSource ( ) ;
56
+ var started = new TaskCompletionSource < bool > ( ) ;
56
57
57
58
_ = Task . Run ( async ( ) =>
58
59
{
60
+ started . SetResult ( true ) ;
59
61
await foreach ( var value in ListenAsync ( cts . Token ) )
60
62
{
61
63
await callback ( value ) ;
62
64
}
63
65
64
66
} , cts . Token ) ;
65
67
68
+ started . Task . GetAwaiter ( ) . GetResult ( ) ;
69
+
66
70
return cts ;
67
71
}
68
72
@@ -76,15 +80,19 @@ public IAsyncEnumerable<T> ListenAsync(CancellationToken cancellationToken)
76
80
public CancellationTokenSource RunListener ( Action < T > callback )
77
81
{
78
82
var cts = new CancellationTokenSource ( ) ;
83
+ var started = new TaskCompletionSource < bool > ( ) ;
79
84
80
85
_ = Task . Run ( ( ) =>
81
86
{
87
+ started . SetResult ( true ) ;
82
88
foreach ( var value in Listen ( cts . Token ) )
83
89
{
84
90
callback ( value ) ;
85
91
}
86
92
} , cts . Token ) ;
87
93
94
+ started . Task . GetAwaiter ( ) . GetResult ( ) ;
95
+
88
96
return cts ;
89
97
}
90
98
You can’t perform that action at this time.
0 commit comments