Cancel all async tasks
<p>Is it possible to cancel all async methods, without knowing what is currently running?</p>

<p>For example I have several classes that may run async tasks:</p>

<pre><code>class Class1
{
    public async void SomeTask()
    {
        for (int i = 0; i &lt; 5; i++)
        {
            // Doing some job
            await Task.Delay(2000);
        }
    }
}

class Class2
{
    public async void ContinuouslyTask()
    {
        for (;;)
        {
            // Doing some job on background
            await Task.Delay(1000);
        }
    }
}
</code></pre>

<p>And I want turn off every async task, before I will logout:</p>

<pre><code>class Program
{
    static void Main(string[] args)
    {
        var p = new Program();
        var c1 = new Class1();
        var c2 = new Class2();

        c1.SomeTask();
        c2.ContinuouslyTask(); 

        while (Console.ReadKey().Key != ConsoleKey.Enter) { }

        p.Logout();
    }

    private void Logout()
    {
        // Cancel all async tasks

        // And do logout work
    }
}
</code></pre>

<p>Is it possible to do this, without saving tasks into query?</p>