コード例 #1
0
 public async Task HandleAsyncAfter(AsyncResource resource, bool throwException)
 {
     try
     {
         await resource.OpenAsync(throwException);
     }
     catch (Exception exception)
     {
         await resource.LogAsync(exception);
     }
     finally
     {
         await resource.CloseAsync();
     }
 }
コード例 #2
0
        private static async Task HandleAsyncBefore(AsyncResource resource, bool throwException)
        {
            Exception exceptionToLog = null;

            try
            {
                await resource.OpenAsync(throwException);
            }
            catch (Exception exception)
            {
                exceptionToLog = exception;
            }
            if (exceptionToLog != null)
            {
                await resource.LogAsync(exceptionToLog);
            }
        }