I'm developing a C#/WPF Application running lengthy data Uploads to a server. For this, I launch a dialog window, which launches a backgroundWorker thread. The worker thread processes the file uploads. The UI Updates are done with Application.Dispatcher.BeginInvoke() calls. The file uploads use HttpClient, calling Task.Run() for the async part.
After a long time ( 1h1/2, 2hrs..) , I have an exception on the GC Finalizer thread:
WindowsBase.dll!System.Windows.Threading.Dispatcher.OnRequestProcessingFailure(string methodName) Unknown WindowsBase.dll!System.Windows.Threading.Dispatcher.RequestForegroundProcessing() Unknown WindowsBase.dll!System.Windows.Threading.Dispatcher.CriticalRequestProcessing(bool force) Unknown WindowsBase.dll!System.Windows.Threading.Dispatcher.InvokeAsyncImpl(System.Windows.Threading.DispatcherOperation operation, System.Threading.CancellationToken cancellationToken) Unknown WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyBeginInvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.Delegate method, object args, int numArgs) Unknown WindowsBase.dll!MS.Win32.HwndWrapper.Dispose(bool disposing, bool isHwndBeingDestroyed) Unknown WindowsBase.dll!MS.Win32.HwndWrapper.~HwndWrapper() Unknown
The exception is an InvalidOperationException, HResult 0x80131509, with the following message:
The Dispatcher is unable to request processing. This is often because the application has starved the Dispatcher's message pump.
I don't understand what this exception means ? I can't find any explanation on the NET..
I had an issue where the dispatcher could not process the messages from the worker thread because there were too many, and added a a Hook on the Dispatcher to watch the queue length. When the exception is triggered, the queue length is small ( < 10).
The Main Thread seems to be running the dispatcher's message pump:
WindowsBase.dll!MS.Win32.UnsafeNativeMethods.GetMessageW(ref System.Windows.Interop.MSG msg, System.Runtime.InteropServices.HandleRef hWnd, int uMsgFilterMin, int uMsgFilterMax) Unknown WindowsBase.dll!System.Windows.Threading.Dispatcher.GetMessage(ref System.Windows.Interop.MSG msg, System.IntPtr hwnd, int minMessage, int maxMessage) Unknown WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame) Unknown PresentationFramework.dll!System.Windows.Window.ShowHelper(object booleanBox) Unknown PresentationFramework.dll!System.Windows.Window.ShowDialog() Unknown
Any hint on how to fix this will be greatly appreciated :-)
User contributions licensed under CC BY-SA 3.0