<PackageReference Include="System.Reactive" Version="6.1.0-preview.9" />

ExceptionHelper

static class ExceptionHelper
Utility methods to handle lock-free combining of Exceptions as well as hosting a terminal-exception indicator for lock-free termination support.
using System.IO; using System.Runtime.CompilerServices; using System.Threading; namespace System.Reactive { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] internal static class ExceptionHelper { public static Exception Terminated { get; } = new EndOfStreamException("On[Error|Completed]"); public static bool TrySetException([System.Runtime.CompilerServices.Nullable(2)] ref Exception field, Exception ex) { return Interlocked.CompareExchange(ref field, ex, null) == null; } } }