I have a doubt with cancellation token source which I am using as shown in the below code:

```
    void Process()
    {
        //for the sake of simplicity I am taking 1, in original implementation it is more than 1
        var cancellationToken = _cancellationTokenSource.Token;
        Task[] tArray = new Task[1];
        tArray[0] = Task.Factory.StartNew(() =>
        {
            cancellationToken.ThrowIfCancellationRequested();
            //do some work here
            MainTaskRoutine();
        }, cancellationToken);

        try
        {
            Task.WaitAll(tArray);
        }
        catch (Exception ex)
        {
            //do error handling here
        }
    }

    void MainTaskRoutine()
    {
        //for the sake of simplicity I am taking 1, in original implementation it is more than 1
        //this method shows that a nested task is created 
        var cancellationToken = _cancellationTokenSource.Token;
        Task[] tArray = new Task[1];
        tArray[0] = Task.Factory.StartNew(() =>
        {
            cancellationToken.ThrowIfCancellationRequested();
            //do some work here

        }, cancellationToken);

        try
        {
            Task.WaitAll(tArray);
        }
        catch (Exception ex)
        {
         //do error handling here
        }
    }

```

---

**Edit:** further elaboration

**End objective is:** when a user cancels the operation, all the immediate pending tasks(either children or grand children) should cancel. 

**Scenario:**
As per above code: 
1. I first check whether user has asked for cancellation 
2. If user has not asked for cancellation then only continue with the task (Please see Process method). 
sample code shows only one task here but actually there can be three or more

Lets say that CPU started processing Task1 while other tasks are still in the Task queue waiting for some CPU to come and execute them. 
User requests cancellation: Task 2,3 in Process method are immediately cancelled, but Task 1 will continue to work since it is already undergoing processing.

In Task 1 it calls method MainTaskRoutine, which in turn creates more tasks. 

In the function of MainTaskRoutine I have written: cancellationToken.ThrowIfCancellationRequested(); 

**So the question is:** is it correct way of using CancellationTokenSource as it is dependent on Task.WaitAll()?