{"record":{"id":"7ec3842cdd618021","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-continuation","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'continuation')","messagePattern":"Value cannot be null\\. \\(Parameter 'continuation'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerOperation.cs","lineNumber":93,"sourceCode":"        /// <summary>\n        /// Indicates whether the scheduler operation has completed. Returns false unless cancellation was already requested.\n        /// </summary>\n        public bool IsCompleted => _cancellationToken.IsCancellationRequested;\n\n        /// <summary>\n        /// Completes the scheduler operation, throwing an OperationCanceledException in case cancellation was requested.\n        /// </summary>\n        public void GetResult() => _cancellationToken.ThrowIfCancellationRequested();\n\n        /// <summary>\n        /// Registers the continuation with the scheduler operation.\n        /// </summary>\n        /// <param name=\"continuation\">Continuation to be run on the originating scheduler.</param>\n        public void OnCompleted(Action continuation)\n        {\n            if (continuation == null)\n            {\n                throw new ArgumentNullException(nameof(continuation));\n            }\n\n            if (_continuation != null)\n            {\n                throw new InvalidOperationException(Strings_Core.SCHEDULER_OPERATION_ALREADY_AWAITED);\n            }\n\n            if (_postBackToOriginalContext)\n            {\n                var ctx = SynchronizationContext.Current;\n                if (ctx != null)\n                {\n                    var original = continuation;\n                    continuation = () =>\n                    {\n                        //\n                        // No need for OperationStarted and OperationCompleted calls here;\n                        // this code is invoked through await support and will have a way","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerOperation.cs#L75-L111","documentation":"SchedulerOperation implements the awaitable pattern for scheduler operations; OnCompleted registers the continuation passed by the compiler-generated awaiter. It throws ArgumentNullException when continuation is null. The compiler normally always passes a valid continuation, so this typically indicates manual/incorrect awaiter usage.","triggerScenarios":"Calling operation.OnCompleted(null) directly; implementing a custom awaiter that passes a null continuation; misuse of the awaitable from another language or generated code.","commonSituations":"Hand-rolled awaiter implementations; reflection-based code invoking OnCompleted; tests exercising the awaitable pattern manually.","solutions":["Always pass a non-null Action continuation to OnCompleted","Await the SchedulerOperation with normal await syntax instead of calling OnCompleted manually","Fix custom awaiter code to forward the real continuation"],"exampleFix":"// before\noperation.OnCompleted(null);\n// after\noperation.OnCompleted(() => Console.WriteLine(\"resumed\"));\n// or simply:\nawait operation;","handlingStrategy":"validation","validationCode":"if (continuation != null) operation.OnCompleted(continuation);","typeGuard":"static bool CanRegister(Action c) => c != null;","tryCatchPattern":"try { operation.OnCompleted(continuation); }\ncatch (ArgumentNullException) { /* supply a real continuation or skip */ }","preventionTips":["Prefer await over manual OnCompleted calls","In custom awaiters, always forward the compiler-provided continuation","Never invoke awaiter plumbing with null delegates in tests"],"tags":["null-argument","async-await","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"}