때때로 이상한 문제가 발생하는 WPF 응용 프로그램에서 작업 중이며 UI에이 응답하지 않는 것 같습니다. 그것은 서로 다른 페이지에서 발생하지만 일관성이 없지만 큰 문제가되는 경우가 종종 발생합니다. 아래에 설명 된대로 그것이 진정한 행방이 아니라는 것을 언급해야합니다.WPF UI 문제를 어떻게 해결합니까?
첫 번째 생각은 일부 버튼의 애니메이션이 대부분의 페이지에서 사용 되었기 때문에 문제 였지만 제거한 후에도 조금 덜 자주 보였지만 멈춤이 여전히 발생했습니다. 중단이 발생하면 디버거를 중단하려고했습니다. 그러나 볼 코드가 전혀 없습니다. 내 코드는 실행되고 있지 않습니다. 나는 또한 "정지"가 완전하지 않다는 것을 알아 차렸다. 폼을 끌기 위해 (테두리 나 제목이없는) 코드를 가지고 있습니다.이 코드는 계속 작동합니다. 또한 클릭 할 때 작동하는 원 클릭 버튼이 있습니다. 버튼을 클릭하면 코드가 실행될 때 실제로 작동하지만 사용자 인터페이스는 단순히 새로운 페이지를 표시하기 위해 업데이트되지 않습니다.
이 이상한 문제를 추적 할 수있는 조언, 도구 또는 기술을 찾고 있습니다. 아무런 생각이 없으면 크게 감사하겠습니다.
편집 : 다시 한 번 일어 났으므로 이번에는 디버거를 깰 때 "해체"를 선택했습니다. 그것은 나를 MS.Win32.UnsafeNativeMethods.GetMessageW로 데려옵니다. 스택 추적은 다음과 같습니다!
[Managed to Native Transition]
수 WindowsBase.dll MS.Win32.UnsafeNativeMethods.GetMessageW (REF System.Windows.Interop.MSG MSG, System.Runtime.InteropServices.HandleRef HWND, INT uMsgFilterMin, INT uMsgFilterMax) + 0x15 바이트
WindowsBase.dll! System.Windows.Threading.Dispatcher.GetMessage (System.Windows.Interop.MSG msg, System.IntPtr hwnd, int minMessage, int maxMessage) + 0x48 바이트 WindowsBase.dll! System .Windows.Threading.Dispatcher.PushFrameImpl (System.Windows.Threading.DispatcherFrame frame = {System.Windows.Threading.DispatcherFrame}) + 0x8b bytes WindowsBase.dll! System.Windows.Threading.Dispatcher. PushFrame (System.Windows.Threading.DispatcherFrame 프레임) + 0x49 바이트
WindowsBase.dll! System.Windows.Threading.Dispatcher.Run() + 0x4c 바이트
PresentationFramework.dll! System.Windows.Application.RunDispatcher (object ignore) + 0x1e 바이트
PresentationFramework.dll! System.Windows.Application.RunInternal (System.Windows.Window 윈도우) + 0x6f 바이트 PresentationFramework.dll! System.Windows.Application.Run (System.Windows.Window 윈도우) + 0x26 바이트 PresentationFramework.dll! System.Windows.Application.Run() +의 0x19 바이트 WinterGreen.exe! WinterGreen.App.Main() + 0x5e 바이트 C# [관리 전환 네이티브]
[Nativ 그럭저럭 전자의 천이가 mscorlib.dll
! System.AppDomain.nExecuteAssembly (System.Reflection.Assembly 조립체 문자열 [] 인수) +의 0x19 바이트 가 mscorlib.dll! System.Runtime.Hosting.ManifestRunner.Run (BOOL checkAptModel) + 0x6e 바이트 가 mscorlib.dll! System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly() + 0x84 바이트 가 mscorlib.dll! System.Runtime.Hosting.ApplicationActivator.CreateInstance (System.ActivationContext activationContext 문자열 [] activationCustomData) + 0x65 바이트 mscorlib에 (System.ActivationContext activationContext) + 0xa 바이트 mscorlib.dll! System.Activator.CreateInstance (System.ActivationContext activationContext) + 0x3e 바이트
Microsoft.VisualStudio. HostingProcess.Utilities.dll! Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone() + 0x23 bytes
mscorlib.dll! System.Threading.ThreadHelper.ThreadStart_Context (개체 상태) + 0x66 바이트
가 mscorlib.dll! System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext의 ExecutionContext, System.Threading.ContextCallback 콜백, 객체 상태) + 0x6f 바이트
가 mscorlib.dll! System.Threading.ThreadHelper.ThreadStart() + 0x44 bytes
일부 비동기 프로세스가 실행되는 경우가 있습니다. 그러나이 동작은 거의 아무것도 실행되지 않은 시작 직후를 포함하여 언제든지 발생할 수 있습니다. 경계선없는 동작을 제거해 봅니다. – palehorse
장래에 다른 사람들이 읽고있는 메모 : Dispatcher에서 장기 실행 작업을 수행하지 마십시오 (BeginInvoke() 또는 BeginInvoke()). UI가 정지 한 것처럼 보입니다 ... 스레드 또는 BackgroundWorker 또는 비슷한 것을 사용하십시오. –
Bob이 맞습니다. 한 번에 UI 스레드에서 너무 많이 수행하면 UI가 응답하지 않게됩니다. UI 스레드에서 가능한 한 작게하고 싶습니다. 큰 작업은 백그라운드 스레드에서 수행해야합니다. –