本文整理汇总了C#中System.Threading.CancellationTokenSource.Cancel方法的典型用法代码示例。如果您正苦于以下问题:C# System.Threading.CancellationTokenSource.Cancel方法的具体用法?C# System.Threading.CancellationTokenSource.Cancel怎么用?C# System.Threading.CancellationTokenSource.Cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Threading.CancellationTokenSource
的用法示例。
在下文中一共展示了System.Threading.CancellationTokenSource.Cancel方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run(IBackgroundTaskInstance taskInstance)
{
// Check the task cost
var cost = BackgroundWorkCost.CurrentBackgroundWorkCost;
if (cost == BackgroundWorkCostValue.High)
{
return;
}
// Get the cancel token
var cancel = new System.Threading.CancellationTokenSource();
taskInstance.Canceled += (s, e) =>
{
cancel.Cancel();
cancel.Dispose();
};
// Get deferral
var deferral = taskInstance.GetDeferral();
try
{
// Update Tile with the new xml
XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml(TileUpdaterTask.w10TileXml);
TileNotification tileNotification = new TileNotification(xmldoc);
TileUpdater tileUpdator = TileUpdateManager.CreateTileUpdaterForApplication();
tileUpdator.Update(tileNotification);
}
finally
{
deferral.Complete();
}
}
示例2: MusicPlayer_PlaysMusic
public void MusicPlayer_PlaysMusic()
{
System.Diagnostics.Trace.WriteLine("Started");
MusicPlayer p = new MusicPlayer();
var ts = new System.Threading.CancellationTokenSource();
p.MuteUnMute();
Task.Factory.StartNew(p.PlayMusic, null, ts.Token);
System.Threading.Thread.Sleep(200);
string track1 = p.CurrentlyPlaying;
System.Diagnostics.Trace.WriteLine("Playing 1:" + track1.ToString());
p.PlayNext();
Assert.IsFalse(string.IsNullOrWhiteSpace(track1));
ts.Cancel(true);
System.Diagnostics.Trace.WriteLine("Stopped");
}
示例3: Launcher_BuildUpdated
void Launcher_BuildUpdated(Client.Launcher.BuildUpdatedEventArgs e)
{
HashSet<Settings.IDatFile> dats = new HashSet<Settings.IDatFile>();
List<Settings.IAccount> accounts = new List<Settings.IAccount>();
//only accounts with a unique dat file need to be updated
foreach (ushort uid in Settings.Accounts.GetKeys())
{
var a = Settings.Accounts[uid];
if (a.HasValue && (a.Value.DatFile == null || dats.Add(a.Value.DatFile)))
{
accounts.Add(a.Value);
}
}
if (accounts.Count > 0)
{
System.Threading.CancellationTokenSource cancel = new System.Threading.CancellationTokenSource(3000);
try
{
this.BeginInvoke(new MethodInvoker(
delegate
{
BeforeShowDialog();
try
{
activeWindows++;
using (formUpdating f = new formUpdating(accounts, true, true))
{
f.Shown += delegate
{
cancel.Cancel();
};
f.ShowDialog(this);
}
}
finally
{
activeWindows--;
}
}));
}
catch { }
try
{
cancel.Token.WaitHandle.WaitOne();
}
catch (Exception ex)
{
ex = ex;
}
e.Update(accounts);
}
}
示例4: Run
Run()
{
Log.Detail("Running build");
// TODO: should the rank collections be sorted, so that modules with fewest dependencies are first?
var graph = Graph.Instance;
var metaDataType = graph.BuildModeMetaData.GetType();
var useEvaluation = CheckIfModulesNeedRebuilding(metaDataType);
var explainRebuild = CommandLineProcessor.Evaluate(new Options.ExplainBuildReason());
var immediateOutput = CommandLineProcessor.Evaluate(new Options.ImmediateOutput());
ExecutePreBuild(metaDataType);
if (!System.IO.Directory.Exists(graph.BuildRoot))
{
System.IO.Directory.CreateDirectory(graph.BuildRoot);
}
var threadCount = CommandLineProcessor.Evaluate(new Options.MultiThreaded());
if (0 == threadCount)
{
threadCount = System.Environment.ProcessorCount;
}
System.Exception abortException = null;
if (threadCount > 1)
{
var cancellationSource = new System.Threading.CancellationTokenSource();
var cancellationToken = cancellationSource.Token;
// LongRunning is absolutely necessary in order to achieve paralleism
var creationOpts = System.Threading.Tasks.TaskCreationOptions.LongRunning;
var continuationOpts = System.Threading.Tasks.TaskContinuationOptions.LongRunning;
var scheduler = new LimitedConcurrencyLevelTaskScheduler(threadCount);
var factory = new System.Threading.Tasks.TaskFactory(
cancellationToken,
creationOpts,
continuationOpts,
scheduler);
var tasks = new Array<System.Threading.Tasks.Task>();
foreach (var rank in graph.Reverse())
{
foreach (var module in rank)
{
var context = new ExecutionContext(useEvaluation, explainRebuild, immediateOutput);
var task = factory.StartNew(() =>
{
if (cancellationToken.IsCancellationRequested)
{
return;
}
var depTasks = new Array<System.Threading.Tasks.Task>();
foreach (var dep in module.Dependents)
{
if (null == dep.ExecutionTask)
{
continue;
}
depTasks.Add(dep.ExecutionTask);
}
foreach (var dep in module.Requirements)
{
if (null == dep.ExecutionTask)
{
continue;
}
depTasks.Add(dep.ExecutionTask);
}
System.Threading.Tasks.Task.WaitAll(depTasks.ToArray());
if (cancellationToken.IsCancellationRequested)
{
return;
}
try
{
(module as IModuleExecution).Execute(context);
}
catch (Exception ex)
{
abortException = ex;
cancellationSource.Cancel();
}
finally
{
if (context.OutputStringBuilder != null && context.OutputStringBuilder.Length > 0)
{
Log.Info(context.OutputStringBuilder.ToString());
}
if (context.ErrorStringBuilder != null && context.ErrorStringBuilder.Length > 0)
{
Log.Info(context.ErrorStringBuilder.ToString());
}
}
});
tasks.Add(task);
//.........这里部分代码省略.........
示例5: SimilarTasksWithWhenAny
private async void SimilarTasksWithWhenAny(object sender, RoutedEventArgs e)
{
ResultTextBlock.Text = "Testing... Please Wait.";
var timer = new System.Diagnostics.Stopwatch();
timer.Start();
var tokenSource = new System.Threading.CancellationTokenSource();
var tasks = new System.Threading.Tasks.Task<string>[10] {
CancellableDummyTask(new Uri("http://stackoverflow.com/"), tokenSource.Token),
CancellableDummyTask(new Uri("http://stackoverflow.com/"), tokenSource.Token),
CancellableDummyTask(new Uri("http://stackoverflow.com/"), tokenSource.Token),
CancellableDummyTask(new Uri("http://stackoverflow.com/"), tokenSource.Token),
CancellableDummyTask(new Uri("http://stackoverflow.com/"), tokenSource.Token),
CancellableDummyTask(new Uri("http://stackoverflow.com/"), tokenSource.Token),
CancellableDummyTask(new Uri("http://stackoverflow.com/"), tokenSource.Token),
CancellableDummyTask(new Uri("http://stackoverflow.com/"), tokenSource.Token),
CancellableDummyTask(new Uri("http://stackoverflow.com/"), tokenSource.Token),
CancellableDummyTask(new Uri("http://stackoverflow.com/"), tokenSource.Token),
};
var results = await System.Threading.Tasks.Task.WhenAny<string>(tasks);
tokenSource.Cancel();
timer.Stop();
ResultTextBlock.Text = "Scenario: Similar Tasks Scenario With WhenAny.\n" + timer.Elapsed.TotalMilliseconds + " Milli Seconds the First Task to Complete.";
}
示例6: Main
static void Main(string[] args)
{
for (int i = 0; i < 20; i++)
{
var rand = new Random();
LockHelper lockhelp = new MonitorLockHelper();
var sw = new System.Diagnostics.Stopwatch();
int[] range = Enumerable.Range(1, (int)Math.Pow(2.0, 23)).ToArray();
//sw.Restart();
//var btTestNoLookupSTRand = new btree(lockhelp);
//RandomRangeInsert(btTestNoLookupSTRand, range, sw, true);
//sw.Stop();
//Console.WriteLine("Random insert single threaded time {0}ms for {1} nodes", sw.Elapsed.TotalMilliseconds, (int)Math.Pow(2.0, 24));
//sw.Restart();
//var btTestNoLookupRand = new btree(lockhelp);
//RandomRangeInsert(btTestNoLookupRand, range, sw);
//Task.WaitAll(wh.ToArray());
//sw.Stop();
//wh.Clear();
//Console.WriteLine("Random insert multi threaded time {0}ms for {1} nodes", sw.Elapsed.TotalMilliseconds, (int)Math.Pow(2.0, 24));
//sw.Restart();
//var btTestNoLookupsST = new btree(lockhelp);
//BalancedRangeInsert(btTestNoLookupsST, range, sw, true);
//sw.Stop();
//Console.WriteLine("Balanced insert single threaded time {0}ms for {1} nodes", sw.Elapsed.TotalMilliseconds, (int)Math.Pow(2.0, 24));
//sw.Restart();
//var btTestNoLookups = new btree(lockhelp);
//BalancedRangeInsert(btTestNoLookups, range, sw);
//Task.WaitAll(wh.ToArray());
//sw.Stop();
//wh.Clear();
//Console.WriteLine("Balanced insert multi threaded time {0}ms for {1} nodes", sw.Elapsed.TotalMilliseconds, (int)Math.Pow(2.0, 24));
sw.Restart();
var bttest = new btree(lockhelp);
BalancedRangeInsert(bttest, range, sw);
var cts = new System.Threading.CancellationTokenSource();
var t = new Task(() =>
{
bool contains = true;
while (!cts.IsCancellationRequested)
{
contains &= bttest.Contains(rand.Next(1, (int)Math.Pow(2.0, 22)));
System.Threading.Thread.Sleep(1);
}
}, cts.Token);
var t2 = new Task(() =>
{
while (!cts.IsCancellationRequested)
{
bttest.Remove(rand.Next(1, (int)Math.Pow(2.0, 22)));
System.Threading.Thread.Sleep(1);
}
}, cts.Token);
t2.Start();
Task.WaitAll(wh.ToArray());
sw.Stop();
cts.Cancel();
Console.WriteLine("Balanced insert multi threaded, w/ lookup and removal time: {0}", sw.Elapsed.TotalMilliseconds);
}
Console.ReadLine();
}
示例7: Main
static void Main(string[] args)
{
"Wake up, HinayakuBot!".COut ();
bool ShutDownFlag = false;
List<Task> Tasks = new List<Task> ();
var CommandContext = new CommandContext ();
var StatusContext = new StatusContext ();
var cts = new System.Threading.CancellationTokenSource ();
Tasks.Add(Task.Run(() => StreamObservable.StreamStart(CommandContext,StatusContext),cts.Token));
Tasks.Add(Task.Run (() => AILogic.AI (CommandContext,StatusContext),cts.Token));
Tasks.Add (Task.Run (() => UserInterface (CommandContext),cts.Token));
System.Threading.Thread.Yield ();
Task.WhenAll (Tasks).ContinueWith (x => ShutDownFlag = true);
CommandContext.GetCommand.Subscribe (x => {
if(x.Keys.Any(y => y == Constant.Cmd)) x[Constant.Cmd].COut();
else if(x.Keys.Any(y => y == Constant.Cmd)&& x[Constant.Cmd] == Constant.CmdEnd) ShutDownFlag = true ;
});
var IDs = GetIdFromXml ();
var Token = TokenCreate (IDs);
var stream = Token.Streaming.UserAsObservable()
.Timeout (TimeSpan.FromSeconds (30))
.Retry (5)
.Catch((Exception e) => {
Console.WriteLine(e.Message);
if(e.StackTrace != null) Console.WriteLine(e.StackTrace);
return Observable.Never<StatusMessage>();
})
.Publish ();
stream
.OfType<StatusMessage>()
.Where (x => !x.Status.User.ScreenName.Contains (@"hinayakuBot"))
.Select (x => new TwString{Name = x.Status.User.ScreenName, Text = x.Status.Text, Id = x.Status.Id})
.Subscribe (x => Console.WriteLine(x.Text));
while(true){
if (ShutDownFlag == true){
Task.Delay (TimeSpan.FromSeconds (15)).Wait ();
cts.Cancel ();
break;
}
}
"All Done".COut ();
}
示例8: UploadFileStreamAsync
// Summary:
// Upload files by output stream.
//
// Parameters:
// sourceFolderId:
// The id of the place you want to upload.
//
// fileName:
// The name you want to use after upload.
//
// Returns:
// The StorageFolder where you downloaded folder.
public async Task<bool> UploadFileStreamAsync(string folderIdToStore, string fileName, Stream outstream)
{
//ProgressBar progressBar = new ProgressBar();
//progressBar.Value = 0;
//var progressHandler = new Progress<LiveOperationProgress>(
// (progress) => { progressBar.Value = progress.ProgressPercentage; });
System.Threading.CancellationTokenSource ctsUpload = new System.Threading.CancellationTokenSource();
try
{
//LiveOperationResult result = await this.LiveClient
// .UploadAsync(folderIdToStore, fileName, outstream, OverwriteOption.Overwrite, ctsUpload.Token, progressHandler);
LiveOperationResult result = await this.LiveClient.BackgroundUploadAsync(folderIdToStore, fileName, outstream.AsInputStream(), OverwriteOption.Overwrite);
}
catch
{
ctsUpload.Cancel();
throw new ShareException(fileName, ShareException.ShareType.UPLOAD);
}
return true;
}
示例9: ReadPartial
/// <summary>
/// This is an internal method called from ReadInternal method.
/// </summary>
/// <param name="buffer">The byte array, passed to Read method.</param>
/// <param name="offset">The offset in the buffer array to begin writing.</param>
/// <param name="count">The number of bytes to read.</param>
/// <param name="timeout">Milliseconds before a time-out occurs.</param>
/// <param name="ct">A cancellation_token will be signaled by user cancellation.</param>
/// <returns>
/// The result of Task contains the length of bytes read. This may be less than count.
/// </returns>
private Task<int> ReadPartial(
Windows.Storage.Streams.IBuffer buffer,
int offset,
int count,
int timeout,
System.Threading.CancellationToken ct
)
{
// Buffer check.
if ((int)buffer.Length < (offset + count))
{
throw new ArgumentException("Capacity of buffer is not enough.");
}
var inputStream = this.cdcData.BulkInPipes[0].InputStream;
var reader = new Windows.Storage.Streams.DataReader(inputStream);
return Task.Run(async () =>
{
// CancellationTokenSource to cancel tasks.
var cancellationTokenSource = new System.Threading.CancellationTokenSource();
// LoadAsync task.
var loadTask = reader.LoadAsync((uint)count).AsTask<uint>(cancellationTokenSource.Token);
// A timeout task that completes after the specified delay.
var timeoutTask = Task.Delay(timeout == Constants.InfiniteTimeout ? System.Threading.Timeout.Infinite : timeout, cancellationTokenSource.Token);
// Cancel tasks by user's cancellation.
bool canceledByUser = false;
ct.Register(()=>
{
canceledByUser = true;
cancellationTokenSource.Cancel();
});
// Wait tasks.
Task[] tasks = { loadTask, timeoutTask };
var signaledTask = await Task.WhenAny(tasks);
// Check the task status.
bool loadCompleted = signaledTask.Equals(loadTask) && loadTask.IsCompleted && !loadTask.IsCanceled;
bool isTimeout = signaledTask.Equals(timeoutTask) && timeoutTask.IsCompleted && !timeoutTask.IsCanceled;
// Cancel all incomplete tasks.
cancellationTokenSource.Cancel();
int loadedCount = 0;
if (loadCompleted)
{
loadedCount = (int)loadTask.Result;
}
else if (isTimeout)
{
// Timeout.
throw new System.TimeoutException("ReadPartial was timeout.");
}
else if (canceledByUser)
{
throw new OperationCanceledException("ReadPartial was canceled.");
}
if (loadedCount > 0)
{
var readBuffer = reader.ReadBuffer((uint)loadedCount);
System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeBufferExtensions.CopyTo(readBuffer, 0, buffer, (uint)offset, (uint)loadedCount);
}
return loadedCount;
});
}
示例10: Handshake
public void Handshake()
{
received = 0;
source = new System.Threading.CancellationTokenSource();
cancel = source.Token;
using (var client = new System.Net.Sockets.TcpClient())
{
client.Connect(Environment.MachineName, port);
using (var stream = client.GetStream())
{
var handshake = Encoding.UTF8.GetBytes("GO");
stream.Write(handshake, 0, handshake.Length);
Task.Run(() => ack_nack(stream));
do
{
int read = stream.Read(buffer, 0, buffer_size);
//System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
//at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
if (read == 0) break;
var block = Encoding.UTF8.GetString(buffer, 0, read);
foreach (var msg in block.Split('\n'))
{
Console.WriteLine($"Received:[{msg}]");
++received;
}
} while (true);
source.Cancel();
}
}
}
示例11: PlayStation
public async void PlayStation(Station s, Windows.UI.Xaml.Controls.MediaElement me, bool navigate = true)
{
if (s == null) return;
if (!NetworkCostController.IsConnectedToInternet) //makes sure Hanasu is connected to the internet.
{
Crystal.Services.ServiceManager.Resolve<Crystal.Services.IMessageBoxService>()
.ShowMessage(
LocalizationManager.GetLocalizedValue("InternetConnectionHeader"),
LocalizationManager.GetLocalizedValue("NoInternetConnectionMsg"));
return;
}
if (NetworkCostController.CurrentNetworkingBehavior == NetworkingBehavior.Opt_In) //if the user is roaming and/or over the data limit, notify them
{
Crystal.Services.ServiceManager.Resolve<Crystal.Services.IMessageBoxService>()
.ShowMessage(
LocalizationManager.GetLocalizedValue("DataConstraintsHeader"),
LocalizationManager.GetLocalizedValue("StreamingDisabled2Msg"));
return;
}
// Reset things things are ready to be played.
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
{
SetMediaElement(ref me);
CurrentStation = s;
CurrentStationSongData = null;
CurrentStationStreamedUri = null;
});
StorageFile albumFile = await GetStationAlbumFromCache(); //Grab the current station's logo from the cache.
if (albumFile != null)
MediaControl.AlbumArt = new Uri("ms-appdata:///local/Hanasu/" + albumFile.DisplayName); //Set the logo in the media control.
MediaControl.ArtistName = CurrentStation.Title; //set the station's name
MediaControl.IsPlaying = true;
try
{
if (me.CurrentState == MediaElementState.Playing || me.CurrentState == MediaElementState.Opening || me.CurrentState == MediaElementState.Buffering)
{
me.Pause();
await Task.Delay(1000);
me.Stop();
}
Uri finalUri = new Uri(s.StreamUrl, UriKind.Absolute);
if (await Hanasu.Core.Preprocessor.PreprocessorService.CheckIfPreprocessingIsNeeded(finalUri, s.PreprocessorFormat))
finalUri = await Hanasu.Core.Preprocessor.PreprocessorService.GetProcessor(finalUri, s.PreprocessorFormat).Process(finalUri);
CurrentStationStreamedUri = finalUri;
//if (CurrentStation.ServerType.ToLower() == "shoutcast")
//{
// var str = await ShoutcastService.GetShoutcastStream(finalUri);
// mediaElement.SetSource(str, str.Content_Type);
// mediaElement.Play();
//}
//else
//{
//finalUri = new Uri(finalUri.ToString() + ";stream.nsv", UriKind.Absolute);
try
{
System.Threading.CancellationTokenSource cts = new System.Threading.CancellationTokenSource();
var openTask = mediaElement.OpenAsync(finalUri, cts.Token);
var timeoutTask = Task.Delay(10000); //Wait for a connection for 10 seconds.
var successful = await Task.WhenAny(openTask, timeoutTask);
if (successful == timeoutTask)
{
//timeout. inform the user and back out.
IsPlaying = false;
Crystal.Services.ServiceManager.Resolve<Crystal.Services.IMessageBoxService>()
.ShowMessage(
LocalizationManager.GetLocalizedValue("StreamingErrorHeader"),
LocalizationManager.GetLocalizedValue("StreamingConnectionTimeoutMsg"));
cts.Cancel();
cts.Dispose();
ResetStationInfo();
return;
}
}
catch (Exception ex)
{
if (ex is TaskCanceledException) return;
//.........这里部分代码省略.........
示例12: TestPerformaceMetrics
public void TestPerformaceMetrics()
{
var ct = new System.Threading.CancellationTokenSource();
var task1 = Task.Run(() =>
{
while (!ct.IsCancellationRequested)
{
var sw = Stopwatch.StartNew();
System.Threading.Thread.Sleep(Convert.ToInt32((new Random()).NextDouble() * 100) + 5);
sw.Stop();
Tracking.Container<PerformanceTracker>
.Where<EnvironmentFilter>(
new EnvironmentFilter
{
ServerName = "Server2"
})
.Increment(e => e.NumberOfCalls, 1)
.Increment(e => e.TotalResponseTimeInMilliseconds, sw);
sw.Reset();
sw.Start();
System.Threading.Thread.Sleep(Convert.ToInt32((new Random()).NextDouble() * 100) + 5);
sw.Stop();
Tracking.Container<PerformanceTracker>
.Where<EnvironmentFilter>(
new EnvironmentFilter
{
ServerName = "Server1"
})
.Increment(e => e.NumberOfCalls, 1)
.Increment(e => e.TotalResponseTimeInMilliseconds, sw);
}
}, ct.Token);
var task2 = Task.Run(() =>
{
while (!ct.IsCancellationRequested)
{
var sw = Stopwatch.StartNew();
System.Threading.Thread.Sleep(Convert.ToInt32((new Random()).NextDouble() * 100) + 5);
sw.Stop();
Tracking.Container<PerformanceTracker>
.Increment(e => e.NumberOfCalls, 1)
.Increment(e => e.TotalResponseTimeInMilliseconds, sw);
}
}, ct.Token);
System.Threading.Thread.Sleep(1000);
ct.Cancel();
Task.WaitAll(task1, task2);
}
示例13: TestNamedMetrics
public void TestNamedMetrics()
{
var ct = new System.Threading.CancellationTokenSource();
var task1 = Task.Run(() =>
{
while (!ct.IsCancellationRequested)
{
Tracking.Container<CustomerAgeTracker>
.Where<CustomerFilter>(
new CustomerFilter
{
State = "MN",
StoreID = "334",
Environment_ServerName = "Server2"
})
.Increment(e => e.MiddleAgedCount, 1)
.Increment(e => e.ElderlyCount, 2);
}
}, ct.Token);
var task2 = Task.Run(() =>
{
while (!ct.IsCancellationRequested)
{
Tracking.Container<CustomerAgeTracker>
.Increment(e => e.KidsCount, 2);
}
}, ct.Token);
System.Threading.Thread.Sleep(1000);
ct.Cancel();
Task.WaitAll(task1, task2);
}
示例14: TestIncrement
public void TestIncrement()
{
var ct = new System.Threading.CancellationTokenSource();
var task1 = Task.Run(() =>
{
while (!ct.IsCancellationRequested)
{
//Graphene.Tracking.Container<PatientLinkValidationTracker>.IncrementBy(1);
Graphene.Tracking.Container<CustomerVisitTracker>
.Where<CustomerFilter>(
new CustomerFilter
{
State = "CA",
StoreID = "3234",
Environment_ServerName = "Server1"
}).IncrementBy(1);
_task1Count++;
// System.Threading.Thread.Sleep(500);
}
}, ct.Token);
var task2 = Task.Run(() =>
{
while (!ct.IsCancellationRequested)
{
Graphene.Tracking.Container<CustomerPurchaseTracker>
.Where<CustomerFilter>(
new CustomerFilter
{
State = "MN",
StoreID = "334",
Environment_ServerName = "Server2"
}).IncrementBy(1);
_task2Count++;
// System.Threading.Thread.Sleep(100);
}
}, ct.Token);
var task3 = Task.Run(() =>
{
while (!ct.IsCancellationRequested)
{
Tracking.Container<CustomerVisitTracker>.IncrementBy(3);
_task3Count++;
//System.Threading.Thread.Sleep(500);
}
}, ct.Token);
System.Threading.Thread.Sleep(1000);
ct.Cancel();
Task.WaitAll(task1, task2, task3);
}