0
私はこれらの2つのメソッドを持っていますが、DoSomethingAsyncがFormatExceptionを返すことは確かです。しかし、常に最後のキャッチで "キャッチされます"例外 "別のタスクメソッドからの特定の例外のキャッチ
なぜCallSomethingAsyncがFormatExceptionを捕まえないのですか?
public Task DoSomethingAsync()
{
//Do something that throws a FormatException
return Task.FromResult(0);
}
public virtual string CallSomethingAsync()
{
try
{
this.DoSomethingAsync().Wait();
return “Ok”;
}
catch (FormatException)
{
return “FormatException”;
}
catch (Exception)
{
return “GeneralException”;
}
}