internal void Attach(RemoteCancellationTokenSource tokenSource) { Debug.Assert(RemotingServices.IsObjectOutOfAppDomain(tokenSource), "Attempt to unwrap remote token source inside the owning AppDomain"); ImmutableInterlockedEx.Add(ref _TokenSources, tokenSource); // Cancel the remote token source if we're already cancelled // This will end up calling Detach, so do it at the end to ensure bookkeeping is consistent if (Token.IsCancellationRequested) { tokenSource.Cancel(); } }
internal void Detach(RemoteCancellationTokenSource tokenSource) { ImmutableInterlockedEx.Remove(ref _TokenSources, tokenSource); }