Await in catch block

前端 未结 9 1499
醉梦人生
醉梦人生 2020-11-28 11:14

I have the following code:

WebClient wc = new WebClient();
string result;
try
{
  result = await wc.DownloadStringTaskAsync( new Uri( \"http://badurl\" ) );
         


        
9条回答
  •  悲哀的现实
    2020-11-28 11:41

    Use C# 6.0. see this Link

    public async Task SubmitDataToServer()
    {
      try
      {
        // Submit Data
      }
      catch
      {
        await LogExceptionAsync();
      }
      finally
      {
        await CloseConnectionAsync();
      }
    }
    

提交回复
热议问题