@@ -47,7 +47,7 @@ public class AmqpManagement : AbstractLifeCycle, IManagement, IManagementTopolog
4747 private const string ReplyTo = "$me" ;
4848
4949 protected readonly TaskCompletionSource < bool > _managementSessionClosedTcs =
50- new ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
50+ Utils . CreateTaskCompletionSource < bool > ( ) ;
5151
5252 internal AmqpManagement ( AmqpManagementParameters amqpManagementParameters )
5353 {
@@ -269,7 +269,7 @@ private async Task EnsureReceiverLinkAsync()
269269 new Target ( ) { Address = ManagementNodeAddress , ExpiryPolicy = new Symbol ( "SESSION_END" ) , } ,
270270 } ;
271271
272- var tcs = new TaskCompletionSource < ReceiverLink > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
272+ TaskCompletionSource < ReceiverLink > tcs = Utils . CreateTaskCompletionSource < ReceiverLink > ( ) ;
273273 var tmpReceiverLink = new ReceiverLink (
274274 _managementSession , LinkPairName , receiveAttach , ( ILink link , Attach attach ) =>
275275 {
@@ -328,7 +328,7 @@ private async Task EnsureSenderLinkAsync()
328328 } ,
329329 } ;
330330
331- var tcs = new TaskCompletionSource < SenderLink > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
331+ TaskCompletionSource < SenderLink > tcs = Utils . CreateTaskCompletionSource < SenderLink > ( ) ;
332332 var tmpSenderLink = new SenderLink (
333333 _managementSession , LinkPairName , senderAttach , ( ILink link , Attach attach ) =>
334334 {
@@ -425,10 +425,10 @@ internal async Task<Message> RequestAsync(Message message, int[] expectedRespons
425425 // TODO: make the timeout configurable
426426 TimeSpan timeout = argTimeout ?? TimeSpan . FromSeconds ( 30 ) ;
427427
428- TaskCompletionSource < Message > mre = new ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
428+ TaskCompletionSource < Message > tcs = Utils . CreateTaskCompletionSource < Message > ( ) ;
429429
430430 // Add TaskCompletionSource to the dictionary it will be used to set the result of the request
431- if ( false == _requests . TryAdd ( message . Properties . MessageId , mre ) )
431+ if ( false == _requests . TryAdd ( message . Properties . MessageId , tcs ) )
432432 {
433433 // TODO what to do in this error case?
434434 }
@@ -461,7 +461,7 @@ void RequestTimeoutAction()
461461
462462 // The response is handled in a separate thread, see ProcessResponses method in the Init method
463463 // TODO timeout & token
464- Message result = await mre . Task . WaitAsync ( linkedCts . Token )
464+ Message result = await tcs . Task . WaitAsync ( linkedCts . Token )
465465 . ConfigureAwait ( false ) ;
466466
467467 await sendTask . WaitAsync ( linkedCts . Token )
0 commit comments