Using ThreadPool to Call Methods in Windows Store Apps RRS feed

  • Question

  • In my VS2013 Win8.1 Windows Store App, I need to do large numbers of calculations on different objects. I thought a ThreadPool would be perfect for this. In the oversimplified following example, I have the following problems:

    My CalcBunch1, CalcBunch2, and CalcBunch3 methods are NOT accepted as parameters for RunAsync. RunAsync wants WorkItemHandler objects, but I cannot find an example (MSDN or otherwise) of how to get my CalcBunch* methods into WorkItemHandler objects.

    I do not see where to get some sort of WaitAll() method to only return when all the CalcBunch* methods complete.

    Any pointers would be appreciated.



    Tuesday, January 28, 2014 6:48 PM


  • i wouldnt use the threadpool, but tas

    public void DoAll()
                var task1 = Task.Run(() => { });
                var task2 = Task.Run(() => { });
                var task3 = Task.Run(() => { });
                Task.WaitAll(task1, task2, task3); // sync
                await Task.WhenAll(task1, task2, task3);

    ks. see this code:

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Tuesday, January 28, 2014 10:16 PM