@@ -360,27 +360,20 @@ public virtual async Task Deadlock()
360
360
var id2 = p2 . Entity . Id ;
361
361
362
362
using var controlContext = new DemoContext ( DemoContext . Options ) ;
363
- using var transaction1 = DemoContext . Database . BeginTransactionAsync ( ) ;
364
- using var transaction2 = controlContext . Database . BeginTransactionAsync ( ) ;
363
+ using var transaction1 = await DemoContext . Database . BeginTransactionAsync ( ) ;
364
+ using var transaction2 = await controlContext . Database . BeginTransactionAsync ( ) ;
365
365
366
366
await DemoContext . Products . Where ( c => c . Id == id1 )
367
367
. ExecuteUpdateAsync ( c => c . SetProperty ( p => p . Name , "Test11" ) ) ;
368
368
369
- await Assert . ThrowsAsync < DeadlockException > ( async ( ) =>
370
- {
371
- await controlContext . Products . Where ( c => c . Id == id2 )
372
- . ExecuteUpdateAsync ( c => c . SetProperty ( p => p . Name , "Test21" ) ) ;
373
-
374
- var task1 = Task . Run ( ( ) => DemoContext . Products . Where ( c => c . Id == id2 )
375
- . ExecuteUpdateAsync ( c => c . SetProperty ( p => p . Name , "Test22" ) ) ) ;
376
-
377
- await Task . Delay ( 100 ) ;
369
+ await controlContext . Products . Where ( c => c . Id == id2 )
370
+ . ExecuteUpdateAsync ( c => c . SetProperty ( p => p . Name , "Test21" ) ) ;
378
371
379
- var task2 = controlContext . Products . Where ( c => c . Id == id1 )
380
- . ExecuteUpdateAsync ( c => c . SetProperty ( p => p . Name , "Test12" ) ) ;
381
-
382
- await Task . WhenAll ( task1 , task2 ) ;
383
- } ) ;
372
+ await Assert . ThrowsAsync < DeadlockException > ( ( ) => Task . WhenAll ( Task . Run ( ( ) => DemoContext . Products
373
+ . Where ( c => c . Id == id2 )
374
+ . ExecuteUpdateAsync ( c => c . SetProperty ( p => p . Name , "Test22" ) ) ) , controlContext . Products
375
+ . Where ( c => c . Id == id1 )
376
+ . ExecuteUpdateAsync ( c => c . SetProperty ( p => p . Name , "Test12" ) ) ) ) ;
384
377
}
385
378
386
379
public virtual void Dispose ( )
0 commit comments