locked
when_all bug

    Question

  • Hi all,

    I create two container of tasks, and only one passed to when_all function. But the result is running both of them. Is this a bug of when_all?

    int _tmain(int argc, _TCHAR* argv[])
    {
        // Start multiple tasks.
        array<task<void>, 3> tasks = {
            task<void>([] { wcout << "Hello from taskA." << endl; }),
            task<void>([] { wcout << "Hello from taskB." << endl; }),
            task<void>([] { wcout << "Hello from taskC." << endl; })
        };
    
    	list<task<void>> tasklist;
    	tasklist.push_back(task<void>([] { wcout << "Hello from taskA1." << endl; }));
    	tasklist.push_back(task<void>([] { wcout << "Hello from taskB1." << endl; }));
    	tasklist.push_back(task<void>([] { wcout << "Hello from taskC1." << endl; }));
        auto joinTask = when_all(tasklist.begin(), tasklist.end());
    
        // Print a message from the joining thread.
        wcout << "Hello from the joining thread." << endl;
    
        // Wait for the tasks to finish.
        joinTask.wait();
    	return 0;
    }
    


    NEU_ShieldEdge

    Sunday, March 18, 2012 7:21 AM

Answers

  • Hello,

    Thanks for your feedback, we will track this issue.

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Monday, March 19, 2012 7:41 AM

All replies

  • Hello,

    Thanks for your feedback, we will track this issue.

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Monday, March 19, 2012 7:41 AM
  • This is an old thread, but in case it helps anyone else -- a task runs when it's created. It's not dependent on whether when_all is called or not. The when_all function allows you to run an additional task when after a set of tasks finish.

    For more info see when_all.

    Thursday, June 6, 2013 9:13 PM