This project is read-only.

WorkItem.runningTasks is constantly growing on Windows Phone


The WorkItem class has the property runningTasks which is of type:
Hashtable<Thread, Stack<Task>>
Thread.CurrentThread is used as the key for this hashtable. In my tests on the Windows Phone Thread.CurrentThread can return different Thread instances for the same thread! This causes the runningTasks hashtable to grow constantly.
To fix this simply use Thread.CurrentThread.ManagedThreadId as the key in the hashtable and not the Thread object itself.
Please note that I use a slightly modified version of your ParallelTasks library but I think the bug and the fix apply to the original code as well.


coach008 wrote Jul 22, 2015 at 10:07 AM