@@ -38,13 +38,13 @@ private async Task<Guid> GetSession()
3838 while ( true )
3939 {
4040 CondenserEventSource . Log . LeadershipSessionCreated ( ) ;
41- var result = await _serviceManager . Client . PutAsync ( HttpUtils . SessionCreateUrl , GetCreateSession ( ) ) ;
41+ var result = await _serviceManager . Client . PutAsync ( HttpUtils . SessionCreateUrl , GetCreateSession ( ) ) . ConfigureAwait ( false ) ;
4242 if ( ! result . IsSuccessStatusCode )
4343 {
4444 await Task . Delay ( 1000 ) ;
4545 continue ;
4646 }
47- return JsonConvert . DeserializeObject < SessionCreateResponse > ( await result . Content . ReadAsStringAsync ( ) ) . Id ;
47+ return JsonConvert . DeserializeObject < SessionCreateResponse > ( await result . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ) . Id ;
4848 }
4949 }
5050
@@ -77,17 +77,17 @@ private StringContent GetServiceInformation() => HttpUtils.GetStringContent(new
7777
7878 private async Task KeepLeadershipLoop ( )
7979 {
80- var sessionId = await _sessionIdTask ;
80+ var sessionId = await _sessionIdTask . ConfigureAwait ( false ) ;
8181 while ( true )
8282 {
83- var leaderResult = await _serviceManager . Client . PutAsync ( $ "{ KeyPath } { _keyToWatch } ?acquire={ sessionId } ", GetServiceInformation ( ) ) ;
83+ var leaderResult = await _serviceManager . Client . PutAsync ( $ "{ KeyPath } { _keyToWatch } ?acquire={ sessionId } ", GetServiceInformation ( ) ) . ConfigureAwait ( false ) ;
8484 if ( ! leaderResult . IsSuccessStatusCode )
8585 {
8686 //error so we need to get a new session
87- await Task . Delay ( 500 ) ;
87+ await Task . Delay ( 500 ) . ConfigureAwait ( false ) ;
8888 continue ;
8989 }
90- var areWeLeader = bool . Parse ( await leaderResult . Content . ReadAsStringAsync ( ) ) ;
90+ var areWeLeader = bool . Parse ( await leaderResult . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ) ;
9191 if ( areWeLeader )
9292 {
9393 _electedLeaderEvent . Set ( true ) ;
@@ -96,15 +96,15 @@ private async Task KeepLeadershipLoop()
9696 {
9797 _electedLeaderEvent . Reset ( ) ;
9898 }
99- await WaitForLeadershipChange ( ) ;
99+ await WaitForLeadershipChange ( ) . ConfigureAwait ( false ) ;
100100 }
101101 }
102102
103103 private async Task WaitForLeadershipChange ( )
104104 {
105105 while ( true )
106106 {
107- using ( var leaderResult = await _serviceManager . Client . GetAsync ( $ "{ KeyPath } { _keyToWatch } ?index={ _consulIndex } ") )
107+ using ( var leaderResult = await _serviceManager . Client . GetAsync ( $ "{ KeyPath } { _keyToWatch } ?index={ _consulIndex } ") . ConfigureAwait ( false ) )
108108 {
109109 if ( ! leaderResult . IsSuccessStatusCode )
110110 {
@@ -115,10 +115,10 @@ private async Task WaitForLeadershipChange()
115115 _currentInfoService . Reset ( ) ;
116116 return ;
117117 }
118- await Task . Delay ( 500 ) ;
118+ await Task . Delay ( 500 ) . ConfigureAwait ( false ) ;
119119 continue ;
120120 }
121- var kv = JsonConvert . DeserializeObject < KeyValue [ ] > ( await leaderResult . Content . ReadAsStringAsync ( ) ) ;
121+ var kv = JsonConvert . DeserializeObject < KeyValue [ ] > ( await leaderResult . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ) ;
122122 if ( string . IsNullOrWhiteSpace ( kv [ 0 ] . Session ) )
123123 {
124124 //no one has leadership
@@ -130,7 +130,7 @@ private async Task WaitForLeadershipChange()
130130 _currentInfoService . Set ( infoService ) ;
131131 _consulIndex = leaderResult . GetConsulIndex ( ) ;
132132 _callback ? . Invoke ( infoService ) ;
133- if ( await _sessionIdTask != new Guid ( kv [ 0 ] . Session ) )
133+ if ( await _sessionIdTask . ConfigureAwait ( false ) != new Guid ( kv [ 0 ] . Session ) )
134134 {
135135 _electedLeaderEvent . Reset ( ) ;
136136 return ;
@@ -141,14 +141,14 @@ private async Task WaitForLeadershipChange()
141141
142142 public async Task < InformationService > GetCurrentLeaderAsync ( )
143143 {
144- await _sessionIdTask ;
145- return await _currentInfoService . WaitAsync ( ) ;
144+ await _sessionIdTask . ConfigureAwait ( false ) ;
145+ return await _currentInfoService . WaitAsync ( ) . ConfigureAwait ( false ) ;
146146 }
147147
148148 public async Task GetLeadershipAsync ( )
149149 {
150- await _sessionIdTask ;
151- await _electedLeaderEvent . WaitAsync ( ) ;
150+ await _sessionIdTask . ConfigureAwait ( false ) ;
151+ await _electedLeaderEvent . WaitAsync ( ) . ConfigureAwait ( false ) ;
152152 }
153153
154154 public void SetLeaderCallback ( Action < InformationService > callback ) => _callback = callback ;
0 commit comments