{"record":{"id":"89a2b0f96d73226a","repo":"dotnet/reactive","slug":"scheduler-observable-async","errorCode":null,"errorMessage":"scheduler","messagePattern":"scheduler","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/Observable.Async.cs","lineNumber":3524,"sourceCode":"        /// <typeparam name=\"TArg11\">The type of the eleventh argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg12\">The type of the twelfth argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg13\">The type of the thirteenth argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg14\">The type of the fourteenth argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg15\">The type of the fifteenth argument passed to the action.</typeparam>\n        /// <param name=\"action\">Action to convert to an asynchronous action.</param>\n        /// <param name=\"scheduler\">Scheduler to invoke the original action on.</param>\n        /// <returns>Asynchronous action.</returns>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"action\"/> or <paramref name=\"scheduler\"/> is null.</exception>\n        public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15> action, IScheduler scheduler)\n        {\n            if (action == null)\n            {\n                throw new ArgumentNullException(nameof(action));\n            }\n\n            if (scheduler == null)\n            {\n                throw new ArgumentNullException(nameof(scheduler));\n            }\n\n            return s_impl.ToAsync(action, scheduler);\n        }\n\n        /// <summary>\n        /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.\n        /// </summary>\n        /// <typeparam name=\"TArg1\">The type of the first argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg2\">The type of the second argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg3\">The type of the third argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg4\">The type of the fourth argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg5\">The type of the fifth argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg6\">The type of the sixth argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg7\">The type of the seventh argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg8\">The type of the eighth argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg9\">The type of the ninth argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg10\">The type of the tenth argument passed to the action.</typeparam>","sourceCodeStart":3506,"sourceCodeEnd":3542,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/Observable.Async.cs#L3506-L3542","documentation":"The 15-argument ToAsync overload with a scheduler throws ArgumentNullException with parameter name 'scheduler' when the IScheduler argument is null. The action check has already passed at this point; Rx requires a concrete scheduler to dispatch the asynchronous action invocation.","triggerScenarios":"Calling Observable.ToAsync(action, (IScheduler)null) with a valid action but a null scheduler reference.","commonSituations":"Uninitialized scheduler fields; DI or configuration not providing a scheduler; passing the result of a GetScheduler() method that returned null; test code forgetting to wire a TestScheduler.","solutions":["Pass Scheduler.Default, Scheduler.TaskPool, Scheduler.ThreadPool, or a custom IScheduler.","Fix the null source of the scheduler (DI registration, config, factory).","Use the single-argument ToAsync overload if default scheduling suffices.","Coalesce: scheduler ?? Scheduler.Default."],"exampleFix":"// before\nObservable.ToAsync(action, configuredScheduler); // configuredScheduler is null\n// after\nObservable.ToAsync(action, configuredScheduler ?? Scheduler.Default);","handlingStrategy":"validation","validationCode":"if (scheduler == null) throw new ArgumentNullException(nameof(scheduler)); // or scheduler ??= Scheduler.Default;","typeGuard":"bool HasScheduler(IScheduler s) => s != null;","tryCatchPattern":"try { Observable.ToAsync(action, scheduler); } catch (ArgumentNullException ex) when (ex.ParamName == \"scheduler\") { /* substitute Scheduler.Default */ }","preventionTips":["Coalesce nullable schedulers: scheduler ?? Scheduler.Default","Register a default IScheduler in your DI container","In tests, always wire a TestScheduler before exercising ToAsync"],"tags":["csharp","rx","null-argument","scheduler"],"backgroundTag":"null-argument","analyzedSha":"94b5d5ab912789f5abe9a72138a25bbd716fe59c","analyzedAt":"2026-09-15T02:26:24.759Z","contentChangedAt":"2026-09-15T02:26:24.759Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}