private static void DoOperations(object objData)
    {
        ThreadData data = (ThreadData)objData;

        try
        {
            // Start scheduling operations from child thread.
            for (int i = 0; i < 5; ++i)
            {
                int t = Thread.CurrentThread.ManagedThreadId;
                int n = i;
                data.ExecuteTask(() => SayHello(t, n));
            }
        }
        finally
        {
            // Child thread is done.
            data.OnThreadCompleted();
        }
    }