Zaman uyumsuz/izleri bekliyor yığını
Yığın izlemelerini Microsoft'un yeni programlama paradigması ile etkilenir neden açık. Biz şimdi bir anlam yığını ve fiziksel olanlar bir çift (kelime seçimim).
Bakın ben ne 3 ** özelliği (debugger) fiziksel olanlar, birleştirilmiş bir istisna vardır:
private async Task CheckFooAndBar()
{
var log = LogManager.GetLogger("Test");
log.Info("CheckFooAndBar");
try
{
await Foo();
}
catch (Exception ex)
{
log.Info("StackTrace of last exception: " ex.StackTrace);
}
Console.ReadKey();
}
private async Task Foo()
{
await Task.Factory.StartNew(() => Thread.Sleep(1000));
await Bar();
await Task.Factory.StartNew(() => Thread.Sleep(1000));
}
private async Task Bar()
{
await Task.Factory.StartNew(() => Thread.Sleep(1000));
throw new Exception();
await Task.Factory.StartNew(() => Thread.Sleep(1000));
}
Bu verir:
StackTrace of last exception: at NLogAsyncExceptionTestCase.Program.<Bar>d__d.MoveNext() in c:\Users\Jens\Documents\Visual Studio 2012\Projects\NLogAsyncExceptionTestCase\NLogAsyncExceptionTestCase.Console\Program.cs:line 53
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at NLogAsyncExceptionTestCase.Program.<Foo>d__8.MoveNext() in c:\Users\Jens\Documents\Visual Studio 2012\Projects\NLogAsyncExceptionTestCase\NLogAsyncExceptionTestCase.Console\Program.cs:line 44
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at NLogAsyncExceptionTestCase.Program.<CheckFooAndBar>d__0.MoveNext() in c:\Users\Jens\Documents\Visual Studio 2012\Projects\NLogAsyncExceptionTestCase\NLogAsyncExceptionTestCase.Console\Program.cs:line 30
Benim sorum: orada uygun bir geri iz semantik anlamda, gibi: dönüştürmek (uygun, standart bir yoldur
CheckFooAndBar
Foo
Bar
Elbette yığında bekliyor ve satır içi yolu parçalarının bir karışımı olabilir.
Olduğu gibi yığın bakmaya çalıştım .NET WinRT ile uyumsuz hedefleme paketi ile, ama henüz 4.5 ve SL5. Çıktı .NET 4.5.
İçinde SL5, ne ben esas olarak, durumu daha da sorunlu: anlamıyorsun Satır Numaraları yığın izleri Silverlight (bile yükseltilmiş ayrıcalıklar), yapan hangi ihtiyacı için içerik daha önemli.
CEVAP
Visual Studio 2013 ve .NET 4.5.1, bu sorunu ele görünüyor değil sadece .NET.
Daha fazla bilgi için this blog post bkz.
Kullanarak zaman uyumsuz bekliyor .net...
Current zaman uyumsuz / çalışmak için ...
Güvenli bir şekilde C zaman uyumsuz yö...
HttpClient.(...) GetAsync asla kullanm...
Kullanarak zaman uyumsuz/çoklu görevle...