File tree Expand file tree Collapse file tree 4 files changed +21
-5
lines changed Expand file tree Collapse file tree 4 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -65,11 +65,10 @@ private void ClipboardStream()
65
65
_clipboardStream = _services . Clipboard . Stream ( ) ;
66
66
Task . Run ( async ( ) =>
67
67
{
68
- while ( await _clipboardStream . MoveNext ( ) )
68
+ await foreach ( var clipboardContent in _clipboardStream . ToAsyncEnumerable ( ) )
69
69
{
70
70
try
71
71
{
72
- var clipboardContent = _clipboardStream . Current ( ) ;
73
72
Logger . Info ( $ "Received Clipboard Update \" { clipboardContent } \" ") ;
74
73
switch ( clipboardContent )
75
74
{
Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Threading ;
2
4
using System . Threading . Tasks ;
3
5
4
6
namespace OliveHelpsLDK
@@ -8,5 +10,7 @@ public interface IStreamingCall<TOutput> : IDisposable
8
10
TOutput Current ( ) ;
9
11
10
12
Task < bool > MoveNext ( ) ;
13
+
14
+ IAsyncEnumerable < TOutput > ToAsyncEnumerable ( CancellationToken cancellationToken = default ) ;
11
15
}
12
16
}
Original file line number Diff line number Diff line change 6
6
</PropertyGroup >
7
7
8
8
<ItemGroup >
9
- <PackageReference Include =" Google.Protobuf" Version =" 3.13.0" />
10
- <PackageReference Include =" Grpc" Version =" 2.33.1" />
11
- <PackageReference Include =" Grpc.Tools" Version =" 2.33.1" >
9
+ <PackageReference Include =" Google.Protobuf" Version =" 3.13.0" />
10
+ <PackageReference Include =" Grpc" Version =" 2.34.0" />
11
+ <PackageReference Include =" Grpc.Net.Common" Version =" 2.34.0" />
12
+ <PackageReference Include =" Grpc.Tools" Version =" 2.34.0" >
12
13
<PrivateAssets >all</PrivateAssets >
13
14
<IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
14
15
</PackageReference >
Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Runtime . CompilerServices ;
4
+ using System . Threading ;
2
5
using System . Threading . Tasks ;
3
6
using Grpc . Core ;
4
7
@@ -30,5 +33,14 @@ public Task<bool> MoveNext()
30
33
{
31
34
return _call . ResponseStream . MoveNext ( ) ;
32
35
}
36
+
37
+ public async IAsyncEnumerable < TOutput > ToAsyncEnumerable (
38
+ [ EnumeratorCancellation ] CancellationToken cancellationToken = default )
39
+ {
40
+ await foreach ( var output in _call . ResponseStream . ReadAllAsync ( cancellationToken ) . ConfigureAwait ( false ) )
41
+ {
42
+ yield return _transformer ( output ) ;
43
+ }
44
+ }
33
45
}
34
46
}
You can’t perform that action at this time.
0 commit comments