{"record":{"id":"e3dba5330081d064","repo":"dotnet/wpf","slug":"sr-dispatcherprocessingdisabled","errorCode":null,"errorMessage":"SR.DispatcherProcessingDisabled","messagePattern":"SR\\.DispatcherProcessingDisabled","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Threading/Dispatcher.cs","lineNumber":314,"sourceCode":"        /// </param>\n        public static void PushFrame(DispatcherFrame frame)\n        {\n            ArgumentNullException.ThrowIfNull(frame);\n\n            Dispatcher dispatcher = Dispatcher.CurrentDispatcher;\n            if(dispatcher._hasShutdownFinished) // Dispatcher thread - no lock needed for read\n            {\n                throw new InvalidOperationException(SR.DispatcherHasShutdown);\n            }\n\n            if(frame.Dispatcher != dispatcher)\n            {\n                throw new InvalidOperationException(SR.MismatchedDispatchers);\n            }\n\n            if(dispatcher._disableProcessingCount > 0)\n            {\n                throw new InvalidOperationException(SR.DispatcherProcessingDisabled);\n            }\n\n            dispatcher.PushFrameImpl(frame);\n        }\n\n        /// <summary>\n        ///     Requests that all nested frames exit.\n        /// </summary>\n        public static void ExitAllFrames()\n        {\n\n            Dispatcher dispatcher = Dispatcher.CurrentDispatcher;\n            if(dispatcher._frameDepth > 0)\n            {\n                dispatcher._exitAllFrames = true;\n\n                // Post a message so that the message pump will wake up and\n                // check our continue state.","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Threading/Dispatcher.cs#L296-L332","documentation":"Dispatcher.PushFrame throws InvalidOperationException with SR.DispatcherProcessingDisabled when the dispatcher's processing is currently disabled (its _disableProcessingCount is greater than zero), i.e. inside a Dispatcher.DisableProcessing scope. Message pumping is prohibited while processing is disabled to protect the dispatcher's internal state.","triggerScenarios":"Calling PushFrame (directly or transitively, e.g. ShowDialog, WaitForPriority) inside a using Dispatcher.DisableProcessing() block, or inside code invoked under DispatcherProcessingDisabledMode; also raised from Invoke-like calls on the dispatcher while processing is disabled.","commonSituations":"Showing a modal dialog or pumping frames inside Dispatcher.DisableProcessing regions used for atomic updates; calling user code that pumps frames from within dispatcher-disabled sections (e.g. property change notifications during processing-disabled scopes).","solutions":["Move the PushFrame/ShowDialog/Invoke call outside the DisableProcessing scope.","Remove the DisableProcessing wrapper if pumping is genuinely needed there.","Disable processing only around short, non-reentrant code that never calls back into the dispatcher.","Restructure so dependent work is queued with Dispatcher.InvokeAsync and executed after processing is re-enabled."],"exampleFix":"// before\nusing (Dispatcher.CurrentDispatcher.DisableProcessing())\n{\n    Dispatcher.PushFrame(new DispatcherFrame());\n}\n// after\nDispatcher.PushFrame(new DispatcherFrame()); // outside the disabled scope","handlingStrategy":"validation","validationCode":"// there is no public query; avoid pumping inside DisableProcessing scopes\nusing (Dispatcher.CurrentDispatcher.DisableProcessing())\n{\n    DoAtomicWork(); // must not call ShowDialog/PushFrame/Invoke\n}\nDispatcher.PushFrame(new DispatcherFrame()); // outside the scope","typeGuard":null,"tryCatchPattern":"try\n{\n    Dispatcher.PushFrame(frame);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"processing\"))\n{\n    // we are inside DisableProcessing; defer the pump\n}","preventionTips":["Never call ShowDialog, WaitForPriority, or PushFrame inside DisableProcessing blocks","Keep DisableProcessing scopes short and free of reentrant dispatcher calls","Run pump-needing code via Dispatcher.InvokeAsync to execute after processing is re-enabled","Review callbacks invoked inside disabled scopes for UI operations"],"tags":["wpf","dispatcher","threading","reentrancy"],"backgroundTag":"invalid-state-transition","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}