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.
http://msdn.microsoft.com/en-us/library/windows/apps/jj248672.aspx
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.
Venkat.
Windows Desktop, Windows Phone developer.