{"record":{"id":"7122ce9481767f76","repo":"dotnet/wpf","slug":"sr-inputprovidersitedisposed","errorCode":null,"errorMessage":"SR.InputProviderSiteDisposed","messagePattern":"SR\\.InputProviderSiteDisposed","errorType":"exception","errorClass":"ObjectDisposedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputProviderSite.cs","lineNumber":80,"sourceCode":"            }\n        }\n\n        /// <summary>\n        ///     Reports input to the input manager.\n        /// </summary>\n        /// <returns>\n        ///     Whether or not any event generated as a consequence of this\n        ///     event was handled.\n        /// </returns>\n        /// <remarks>\n        ///  Do we really need this?  Make the \"providers\" call InputManager.ProcessInput themselves.\n        ///  we currently need to map back to providers for other reasons.\n        /// </remarks>\n        public bool ReportInput(InputReport inputReport)\n        {\n            if(IsDisposed)\n            {\n                throw new ObjectDisposedException(SR.InputProviderSiteDisposed);\n            }\n\n            bool handled = false;\n\n            InputReportEventArgs input = new InputReportEventArgs(null, inputReport)\n            {\n                RoutedEvent = InputManager.PreviewInputReportEvent\n            };\n\n            if (_inputManager is not null)\n            {\n                handled = _inputManager.ProcessInput(input);\n            }\n\n            return handled;\n        }\n\n        private bool _isDisposed;","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputProviderSite.cs#L62-L98","documentation":"InputProviderSite.ReportInput throws ObjectDisposedException(SR.InputProviderSiteDisposed) when the site has already been disposed. An InputProviderSite is the bridge through which raw input providers (e.g. the per-monitor/per-hwnd input provider) deliver reports to the InputManager; once disposed, that channel is permanently invalid and input reports must stop.","triggerScenarios":"Calling ReportInput after InputProviderSite.Dispose() was invoked, e.g. a background input provider thread still pumping events after the PresentationSource/InputManager shut down.","commonSituations":"Shutting down a window or dispatcher while a custom or low-level input provider thread is still running; race between teardown and a queued input event; leaked provider references kept after HwndSource.Close.","solutions":["Check site.IsDisposed before calling ReportInput and skip/report the event as stale.","Ensure the input provider thread is stopped/disposed before or as part of tearing down the PresentationSource.","Catch ObjectDisposedException around ReportInput in provider loops and exit the loop gracefully."],"exampleFix":"// before\nsite.ReportInput(report);\n// after\nif (!site.IsDisposed)\n    site.ReportInput(report);","handlingStrategy":"validation","validationCode":"if (site.IsDisposed) return; // drop stale input report\nsite.ReportInput(report);","typeGuard":"static bool CanReport(InputProviderSite site) => site != null && !site.IsDisposed;","tryCatchPattern":"try { site.ReportInput(report); }\ncatch (ObjectDisposedException) { /* provider shutting down; stop loop */ break; }","preventionTips":["Check IsDisposed before every ReportInput call in provider loops.","Stop input provider threads during PresentationSource teardown, before disposing the site.","Treat ObjectDisposedException from ReportInput as a shutdown signal and exit the loop."],"tags":["wpf","input","disposed","race-condition"],"backgroundTag":"object-disposed","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"}