2020
2121async Task < string > Handler ( ILogger < Program > logger )
2222{
23- await ExecuteSql ( "SELECT 1" ) ;
23+ await ExecuteSql ( "SELECT 1" ) . ConfigureAwait ( false ) ;
2424
2525 // .NET Diagnostics: create a manual span
2626 using ( var activity = activitySource . StartActivity ( "SayHello" ) )
2727 {
2828 activity ? . SetTag ( "foo" , 1 ) ;
2929 activity ? . SetTag ( "bar" , "Hello, World!" ) ;
30- activity ? . SetTag ( "baz" , new int [ ] { 1 , 2 , 3 } ) ;
30+ activity ? . SetTag ( "baz" , ( int [ ] ) [ 1 , 2 , 3 ] ) ;
3131
3232 var waitTime = Random . Shared . NextDouble ( ) ; // max 1 seconds
33- await Task . Delay ( TimeSpan . FromSeconds ( waitTime ) ) ;
33+ await Task . Delay ( TimeSpan . FromSeconds ( waitTime ) ) . ConfigureAwait ( false ) ;
3434
3535 activity ? . SetStatus ( ActivityStatusCode . Ok ) ;
3636
@@ -47,7 +47,9 @@ async Task<string> Handler(ILogger<Program> logger)
4747async Task ExecuteSql ( string sql )
4848{
4949 using var connection = new SqlConnection ( connectionString ) ;
50- await connection . OpenAsync ( ) ;
50+ await connection . OpenAsync ( ) . ConfigureAwait ( false ) ;
51+ #pragma warning disable CA2100 // Review SQL queries for security vulnerabilities. It is static SQL for demo purposes.
5152 using var command = new SqlCommand ( sql , connection ) ;
52- using var reader = await command . ExecuteReaderAsync ( ) ;
53+ #pragma warning restore CA2100 // Review SQL queries for security vulnerabilities. It is static SQL for demo purposes.
54+ using var reader = await command . ExecuteReaderAsync ( ) . ConfigureAwait ( false ) ;
5355}
0 commit comments