@@ -17,7 +17,7 @@ sealed class Program
1717 static async Task Main ( string [ ] args )
1818 {
1919 var url = "http://localhost:8009" ;
20- var proxy = await ConnectAsync ( url , Console . Out ) ;
20+ var proxy = await ConnectAsync ( url , Console . Out ) . ConfigureAwait ( false ) ;
2121 var currentUser = Guid . NewGuid ( ) . ToString ( "N" ) ;
2222
2323 Mode mode = Mode . Broadcast ;
@@ -33,11 +33,11 @@ static async Task Main(string[] args)
3333 switch ( mode )
3434 {
3535 case Mode . Broadcast :
36- await proxy . Invoke ( "BroadcastMessage" , currentUser , input ) ;
36+ await proxy . Invoke ( "BroadcastMessage" , currentUser , input ) . ConfigureAwait ( false ) ;
3737
3838 break ;
3939 case Mode . Echo :
40- await proxy . Invoke ( "echo" , input ) ;
40+ await proxy . Invoke ( "echo" , input ) . ConfigureAwait ( false ) ;
4141 break ;
4242 default :
4343 break ;
@@ -71,15 +71,15 @@ private static async Task<IHubProxy> ConnectAsync(string url, TextWriter output,
7171 hubProxy . On < string , string > ( "BroadcastMessage" , BroadcastMessage ) ;
7272 hubProxy . On < string > ( "Echo" , Echo ) ;
7373
74- await StartAsyncWithAlwaysRetry ( connection , output , cancellationToken : cancellationToken ) ;
74+ await StartAsyncWithAlwaysRetry ( connection , output , cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ;
7575
7676 return hubProxy ;
7777 }
7878
7979 private static async Task StartAsyncWithAlwaysRetry ( HubConnection connection , TextWriter output , Task startDelay = null , CancellationToken cancellationToken = default )
8080 {
8181 // When there is already a reconnect, directly return;
82- if ( ! ReconnectLock . Wait ( 0 ) )
82+ if ( ! ReconnectLock . Wait ( 0 , CancellationToken . None ) )
8383 {
8484 return ;
8585 }
@@ -88,21 +88,21 @@ private static async Task StartAsyncWithAlwaysRetry(HubConnection connection, Te
8888 {
8989 if ( startDelay != null )
9090 {
91- await startDelay ;
91+ await startDelay . ConfigureAwait ( false ) ;
9292 }
9393
9494 while ( ! cancellationToken . IsCancellationRequested )
9595 {
9696 try
9797 {
9898 // Sometimes Start throws and triggers Error event, however sometimes not.
99- await connection . Start ( ) ;
99+ await connection . Start ( ) . ConfigureAwait ( false ) ;
100100 return ;
101101 }
102102 catch ( Exception e )
103103 {
104104 output . WriteLine ( $ "Error starting: { e . Message } , retry...") ;
105- await ReconnectDelayTask ( ) ;
105+ await ReconnectDelayTask ( ) . ConfigureAwait ( false ) ;
106106 }
107107 }
108108 }
0 commit comments