Created
August 16, 2023 12:31
-
-
Save EifelMono/7a1b71d85593685d056dd9bb48c088fd to your computer and use it in GitHub Desktop.
CreateLinkedTokenSource
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
var cs1= new CancellationTokenSource (); | |
var cs2= new CancellationTokenSource (); | |
var cs3= CancellationTokenSource.CreateLinkedTokenSource(cs1.Token, cs2.Token); | |
Console.WriteLine($"cs1.IsCancellationRequested {cs1.IsCancellationRequested}"); | |
Console.WriteLine($"cs2.IsCancellationRequested {cs2.IsCancellationRequested}"); | |
Console.WriteLine($"cs3.IsCancellationRequested {cs3.IsCancellationRequested}"); | |
cs3.Cancel(); | |
Console.WriteLine($"cs1.IsCancellationRequested {cs1.IsCancellationRequested}"); | |
Console.WriteLine($"cs2.IsCancellationRequested {cs2.IsCancellationRequested}"); | |
Console.WriteLine($"cs3.IsCancellationRequested {cs3.IsCancellationRequested}"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment