小编Ben*_*Ben的帖子

在Dispatcher上调用时,WPF应用程序处于死锁状态

我们偶尔遇到应用程序死锁的情况,并且调度程序似乎与尝试在调度程序上调用的后台线程发生死锁.我没有看到任何一个线程都有任何被锁定的共享资源.后台线程遇到异常,它最终在app域未处理的异常委托中,因为没有人拿起这个异常.这会调用我们的异常处理程序,其任务是确保将异常对话框放到调度程序上.

有人可以建议我可以找出导致死锁的原因吗?

调度程序堆栈遵循并且看起来不同寻常:

*0. System.Windows.Threading.DispatcherSynchronizationContext.Wait (source line information unavailable)

 1. System.Threading.SynchronizationContext.InvokeWaitMethodHelper (source line information unavailable)
 2. Xceed.Wpf.DataGrid.DeferredOperationManager.Process (source line information unavailable)
 3. Xceed.Wpf.DataGrid.DeferredOperationManager.Dispatched_Process (source line information unavailable)
 4. System.Windows.Threading.ExceptionWrapper.InternalRealCall (source line information unavailable)
 5. System.Windows.Threading.ExceptionWrapper.TryCatchWhen (source line information unavailable)
 6. System.Windows.Threading.Dispatcher.WrappedInvoke (source line information unavailable)
 7. System.Windows.Threading.DispatcherOperation.InvokeImpl (source line information unavailable)
 8. System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext (source line information unavailable)
 9. System.Threading.ExecutionContext.runTryCode (source line information unavailable)
 10. System.Threading.ExecutionContext.RunInternal (source line information unavailable)
 11. System.Threading.ExecutionContext.Run (source line information unavailable)
 12. System.Windows.Threading.DispatcherOperation.Invoke (source line information …
Run Code Online (Sandbox Code Playgroud)

wpf deadlock dispatcher

14
推荐指数
1
解决办法
4749
查看次数

在Process Explorer中调试RtlUserThreadStart

我有一个基于3.5的多线程wpf应用程序.当我通过Process Explorer查看正在运行的线程时,我看到8个线程都具有相同的起始地址,ntdll.dll!RtlUserThreadStart,并且所有8个线程的CPU值均为3-6 +且具有高的Cycles Delta.我无法弄清楚这些线程在做什么.它始终是相同的线程.它永远不会在应用程序的同一个实例中发生变化.当我同时调试我的应用程序并暂停调试器时,所有这些线程都显示堆栈的单行,System.Threading.ConcurrencyScheduler.Scheduler.WaitForWork()或System.Threading.Monitor.Wait().

我启用了Visual Studio的符号文件,我在这些线程上看到了以下堆栈:

System.Threading.Monitor.Wait() Normal
mscorlib.dll!System.Threading.Monitor.Wait(object obj, int millisecondsTimeout) + 0x19     bytes
System.Threading.dll!System.Threading.ConcurrencyScheduler.Scheduler.WaitForWork() + 0xd0 bytes  
System.Threading.dll!System.Threading.ConcurrencyScheduler.InternalContext.Dispatch() + 0x74a bytes
System.Threading.dll!System.Threading.ConcurrencyScheduler.ThreadInternalContext.ThreadStartBridge(System.IntPtr dummy) + 0x9f bytes     
Run Code Online (Sandbox Code Playgroud)

当我查看进程监视器中线程上提供的堆栈时,我看到以下示例:

0  ntoskrnl.exe!KeWaitForMultipleObjects+0xc0a
1  ntoskrnl.exe!KeAcquireSpinLockAtDpcLevel+0x732
2  ntoskrnl.exe!KeWaitForSingleObject+0x19f
3  ntoskrnl.exe!_misaligned_access+0xba4
4  ntoskrnl.exe!_misaligned_access+0x1821
5  ntoskrnl.exe!_misaligned_access+0x1a97
6  mscorwks.dll!InitializeFusion+0x990b
7  mscorwks.dll!DeleteShadowCache+0x31ef
Run Code Online (Sandbox Code Playgroud)

要么:

0  ntoskrnl.exe!KeWaitForMultipleObjects+0xc0a
1  ntoskrnl.exe!KeAcquireSpinLockAtDpcLevel+0x732
2  ntoskrnl.exe!KeWaitForSingleObject+0x19f
3  ntoskrnl.exe!_misaligned_access+0xba4
4  ntoskrnl.exe!_misaligned_access+0x1821
5  ntoskrnl.exe!KeAcquireSpinLockAtDpcLevel+0x93d
6  ntoskrnl.exe!KeWaitForMultipleObjects+0x26a
7  ntoskrnl.exe!NtWaitForSingleObject+0x41f
8  ntoskrnl.exe!NtWaitForSingleObject+0x78e
9  ntoskrnl.exe!KeSynchronizeExecution+0x3a23
10 ntdll.dll!ZwWaitForMultipleObjects+0xa
11 KERNELBASE.dll!GetCurrentProcess+0x40
12 KERNEL32.dll!WaitForMultipleObjectsEx+0xb3
13 mscorwks.dll!CreateApplicationContext+0x10499
14 mscorwks.dll!CreateApplicationContext+0xbc41
15 mscorwks.dll!StrongNameFreeBuffer+0xc54d
16 mscorwks.dll!StrongNameFreeBuffer+0x2ac48 …
Run Code Online (Sandbox Code Playgroud)

c# multithreading process-explorer

4
推荐指数
1
解决办法
2万
查看次数

为什么decimal.TryParse成功解析类似12,2,2,2的东西

如果我执行以下操作:

string teststring = "12,2,2,2";
decimal testdecimal;
decimal.TryParse(teststring, out testdecimal)
Run Code Online (Sandbox Code Playgroud)

这工作,testdecimal最终成为12222.

这不合理/逻辑上不能解析吗?我很惊讶地看到它有效并且很好奇它背后的逻辑是什么允许这个.

c# parsing decimal

4
推荐指数
2
解决办法
155
查看次数