{"record":{"id":"369dbd0fb6b9a56b","repo":"stride3d/stride","slug":"form","errorCode":null,"errorMessage":"form","messagePattern":"form","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Games/Desktop/WindowsMessageLoop.cs","lineNumber":212,"sourceCode":"        /// Runs the specified main loop in the specified context.\n        /// </summary>\n        public static void Run(ApplicationContext context, RenderCallback renderCallback)\n        {\n            Run(context.MainForm, renderCallback);\n        }\n\n        /// <summary>\n        /// Runs the specified main loop for the specified windows form.\n        /// </summary>\n        /// <param name=\"form\">The form.</param>\n        /// <param name=\"renderCallback\">The rendering callback.</param>\n        /// <param name=\"useApplicationDoEvents\">if set to <c>true</c> indicating whether the render loop should use the default <see cref=\"Application.DoEvents\"/> instead of a custom window message loop lightweight for GC. Default is false.</param>\n        /// <exception cref=\"System.ArgumentNullException\">form\n        /// or\n        /// renderCallback</exception>\n        public static void Run(Control form, RenderCallback renderCallback, bool useApplicationDoEvents = false)\n        {\n            if (form == null) throw new ArgumentNullException(\"form\");\n            if (renderCallback == null) throw new ArgumentNullException(\"renderCallback\");\n\n            using (var renderLoop = new WindowsMessageLoop(form) { UseApplicationDoEvents = useApplicationDoEvents })\n            {\n                while (renderLoop.NextFrame())\n                {\n                    renderCallback();\n                }\n            }\n        }\n   }\n}\n#endif\n","sourceCodeStart":194,"sourceCodeEnd":226,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Games/Desktop/WindowsMessageLoop.cs#L194-L226","documentation":"Argument-null validation on the form parameter of WindowsMessageLoop.Run(ApplicationContext, RenderCallback). The run delegates to Run(context.MainForm, renderCallback), and the overload it forwards to throws ArgumentNullException named 'form' when the form is null — i.e. when the ApplicationContext has no main form — because the message loop needs a window to pump messages for.","triggerScenarios":"Calling Run(null, renderCallback) with a null form.","commonSituations":"Form creation failed earlier and returned null; refactoring moved form construction after Run; passing an uninitialized field.","solutions":["Pass a valid, non-null Control/Form instance to Run","Ensure the form is constructed before the render loop starts","Guard construction failures so a null form is never propagated"],"exampleFix":"// before\nWindowsMessageLoop.Run(form, Render); // form null\n// after\nvar form = new RenderForm(\"App\");\nWindowsMessageLoop.Run(form, Render);","handlingStrategy":"validation","validationCode":"if (form is null) throw new InvalidOperationException(\"form must be created before WindowsMessageLoop.Run\");\nWindowsMessageLoop.Run(form, callback);","typeGuard":"bool HasForm(Control? c) => c is not null;","tryCatchPattern":"try { WindowsMessageLoop.Run(form, callback); } catch (ArgumentNullException) { /* form was null; log and abort startup */ }","preventionTips":["Construct the form before starting the render loop","Never pass nullable form fields without null checks"],"tags":["winforms","render-loop","null-argument"],"backgroundTag":"null-argument","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}