@@ -55,7 +55,7 @@ public void SimpleLeaderElection()
55
55
} ;
56
56
57
57
var countdown = new CountdownEvent ( 2 ) ;
58
- Task . Run ( ( ) =>
58
+ Task . Run ( async ( ) =>
59
59
{
60
60
var leaderElector = new LeaderElector ( leaderElectionConfig ) ;
61
61
@@ -71,7 +71,7 @@ public void SimpleLeaderElection()
71
71
countdown . Signal ( ) ;
72
72
} ;
73
73
74
- leaderElector . RunUntilLeadershipLostAsync ( ) . Wait ( ) ;
74
+ await leaderElector . RunUntilLeadershipLostAsync ( ) . ConfigureAwait ( true ) ;
75
75
} ) ;
76
76
77
77
countdown . Wait ( TimeSpan . FromSeconds ( 10 ) ) ;
@@ -147,7 +147,7 @@ public void LeaderElection()
147
147
var lockAStopLeading = new ManualResetEvent ( false ) ;
148
148
var testLeaderElectionLatch = new CountdownEvent ( 4 ) ;
149
149
150
- Task . Run ( ( ) =>
150
+ Task . Run ( async ( ) =>
151
151
{
152
152
var leaderElector = new LeaderElector ( leaderElectionConfigA ) ;
153
153
@@ -164,13 +164,13 @@ public void LeaderElection()
164
164
lockAStopLeading . Set ( ) ;
165
165
} ;
166
166
167
- leaderElector . RunUntilLeadershipLostAsync ( ) . Wait ( ) ;
167
+ await leaderElector . RunUntilLeadershipLostAsync ( ) . ConfigureAwait ( true ) ;
168
168
} ) ;
169
169
170
170
171
171
lockAStopLeading . WaitOne ( TimeSpan . FromSeconds ( 3 ) ) ;
172
172
173
- Task . Run ( ( ) =>
173
+ Task . Run ( async ( ) =>
174
174
{
175
175
var leaderElector = new LeaderElector ( leaderElectionConfigB ) ;
176
176
@@ -186,7 +186,7 @@ public void LeaderElection()
186
186
testLeaderElectionLatch . Signal ( ) ;
187
187
} ;
188
188
189
- leaderElector . RunUntilLeadershipLostAsync ( ) . Wait ( ) ;
189
+ await leaderElector . RunUntilLeadershipLostAsync ( ) . ConfigureAwait ( true ) ;
190
190
} ) ;
191
191
192
192
testLeaderElectionLatch . Wait ( TimeSpan . FromSeconds ( 15 ) ) ;
@@ -256,7 +256,7 @@ public void LeaderElectionWithRenewDeadline()
256
256
} ;
257
257
258
258
var countdown = new CountdownEvent ( 2 ) ;
259
- Task . Run ( ( ) =>
259
+ Task . Run ( async ( ) =>
260
260
{
261
261
var leaderElector = new LeaderElector ( leaderElectionConfig ) ;
262
262
@@ -272,7 +272,7 @@ public void LeaderElectionWithRenewDeadline()
272
272
countdown . Signal ( ) ;
273
273
} ;
274
274
275
- leaderElector . RunUntilLeadershipLostAsync ( ) . Wait ( ) ;
275
+ await leaderElector . RunUntilLeadershipLostAsync ( ) . ConfigureAwait ( true ) ;
276
276
} ) ;
277
277
278
278
countdown . Wait ( TimeSpan . FromSeconds ( 15 ) ) ;
@@ -290,7 +290,7 @@ public void LeaderElectionWithRenewDeadline()
290
290
}
291
291
292
292
[ Fact ]
293
- public void LeaderElectionThrowException ( )
293
+ public async Task LeaderElectionThrowException ( )
294
294
{
295
295
var l = new Mock < ILock > ( ) ;
296
296
l . Setup ( obj => obj . GetAsync ( CancellationToken . None ) )
@@ -305,11 +305,11 @@ public void LeaderElectionThrowException()
305
305
306
306
try
307
307
{
308
- leaderElector . RunUntilLeadershipLostAsync ( ) . Wait ( ) ;
308
+ await leaderElector . RunUntilLeadershipLostAsync ( ) . ConfigureAwait ( true ) ;
309
309
}
310
310
catch ( Exception e )
311
311
{
312
- Assert . Equal ( "noxu" , e . InnerException ? . Message ) ;
312
+ Assert . Equal ( "noxu" , e . Message ) ;
313
313
return ;
314
314
}
315
315
0 commit comments