@@ -39,7 +39,7 @@ public sealed class Broker : IAsyncDisposable
3939 private readonly BiDi _bidi ;
4040 private readonly ITransport _transport ;
4141
42- private readonly ConcurrentDictionary < long , ( Command , TaskCompletionSource < object > ) > _pendingCommands = new ( ) ;
42+ private readonly ConcurrentDictionary < long , ( Command , TaskCompletionSource < EmptyResult > ) > _pendingCommands = new ( ) ;
4343 private readonly BlockingCollection < MessageEvent > _pendingEvents = [ ] ;
4444 private readonly Dictionary < string , Type > _eventTypesMap = [ ] ;
4545
@@ -186,18 +186,19 @@ public async Task ExecuteCommandAsync<TCommand>(TCommand command, CommandOptions
186186
187187 public async Task < TResult > ExecuteCommandAsync < TCommand , TResult > ( TCommand command , CommandOptions ? options )
188188 where TCommand : Command
189+ where TResult : EmptyResult
189190 {
190191 var result = await ExecuteCommandCoreAsync ( command , options ) . ConfigureAwait ( false ) ;
191192
192193 return ( TResult ) result ;
193194 }
194195
195- private async Task < object > ExecuteCommandCoreAsync < TCommand > ( TCommand command , CommandOptions ? options )
196+ private async Task < EmptyResult > ExecuteCommandCoreAsync < TCommand > ( TCommand command , CommandOptions ? options )
196197 where TCommand : Command
197198 {
198199 command . Id = Interlocked . Increment ( ref _currentCommandId ) ;
199200
200- var tcs = new TaskCompletionSource < object > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
201+ var tcs = new TaskCompletionSource < EmptyResult > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
201202
202203 var timeout = options ? . Timeout ?? TimeSpan . FromSeconds ( 30 ) ;
203204
@@ -379,7 +380,7 @@ private void ProcessReceivedMessage(byte[]? data)
379380
380381 var successCommand = _pendingCommands [ id . Value ] ;
381382 var messageSuccess = JsonSerializer . Deserialize ( ref resultReader , successCommand . Item1 . ResultType , _jsonSerializerContext ) ! ;
382- successCommand . Item2 . SetResult ( messageSuccess ) ;
383+ successCommand . Item2 . SetResult ( ( EmptyResult ) messageSuccess ) ;
383384 _pendingCommands . TryRemove ( id . Value , out _ ) ;
384385 break ;
385386
0 commit comments