File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
src/DotNext.Threading/Threading Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -88,15 +88,21 @@ public CancellationToken CancellationOrigin
8888 : Unsafe . Unbox < CancellationToken > ( tokenCopy . Item1 )
8989 : Token ;
9090
91- private protected set => cancellationOrigin = InlineToken ( value ) ;
91+ private protected set
92+ {
93+ var tokenCopy = InlineToken ( value ) ;
94+ Volatile . Write ( ref cancellationOrigin . Item1 , tokenCopy . Item1 ) ;
95+ }
9296 }
9397
9498 /// <summary>
9599 /// Gets a value indicating that this token source is cancelled by the timeout associated with this source,
96100 /// or by calling <see cref="CancellationTokenSource.Cancel()"/> manually.
97101 /// </summary>
98102 [ DebuggerBrowsable ( DebuggerBrowsableState . Never ) ]
99- internal bool IsRootCause => CanInlineToken ? ReferenceEquals ( this , cancellationOrigin . Item1 ) : CancellationOrigin == Token ;
103+ internal bool IsRootCause => CanInlineToken
104+ ? ReferenceEquals ( this , Volatile . Read ( in cancellationOrigin . Item1 ) )
105+ : CancellationOrigin == Token ;
100106
101107 // This property checks whether the reinterpret cast CancellationToken => CancellationTokenSource
102108 // is safe. If not, just box the token.
You can’t perform that action at this time.
0 commit comments