81
1
using System;
2
using System.Diagnostics;
3
using System.Threading;
4
using System.Threading.Tasks;
5
6
namespace WatchLoop
7
{
8
public class Program
9
{
10
static public void Main(string[] args)
11
{
12
var cancellationSource = new CancellationTokenSource();
13
14
WatchExeTime2(InformAboutLongTime, cancellationSource.Token);
15
16
Console.WriteLine("Going to execute a long time operation.");
17
18
Thread.Sleep(1600);
19
cancellationSource.Cancel();
20
21
Console.WriteLine("The long time operation executed");
22
}
23
24
Cached Result