Problem with ThreadPool in Windows 8 RRS feed

  • Question

  • as there is no support for BackgroundWorkerThread in windows 8. i thought of using threadpool. Thread pool also there is a problem if i use asynchronous task inside the threadpool. Threadpool immediately returns the status as completed even though the task is running background.

    My sample code:

     IAsyncAction threadPoolHandler = ThreadPool.RunAsync( async (workItem) =>

    Task.run(async()=>{await this.somelongoperationAsync();});


    threadPoolHandler .Completed = new AsyncActionCompletedHandler((IAsyncAction action, AsyncStatus status)=>
                                _log.Info("task completed");

    In the above sample Completed event is coming before the Task completed in threadpool.

    When i searched in msdn, i found a limitation for theradpool.


    Don't try to create work item handlers that use the async keyword. This can cause unexpected behavior.

    I need help regarding how to solve this kind of problem. Is there any kind of design pattern which solves this problem.

    Note: I am using windows RT API.

    thanks in advance.


    Windows Desktop, Windows Phone developer.

    Friday, December 20, 2013 9:12 AM

All replies