Fragrance
|
Recently I had an interesting problem in my project. We frequently use task across all the code and it has really made our life easy as a developer but definitely there are some downside for it. Code becomes very messy sometime and its very difficult to debug the problem if there are any threading issue and race conditions are equally difficult. So coming back to my problem, I had one function which was returning a Task and and I had a Task.WaitAll return from which the above function was called. So basically it looked as below: Parent Child Task Relation
So from the above code you can see that after creating the parent task I am writing the continue block but I am returning the parent task. Now when code executes the Task.WaitAll, previously I thought that it will also wait for Continue task to complete. But to my surprise that's not that case, it will only wait for parent task to complete and will just move with the code and child task will complete later in separate thread. Now there are multiple ways to fix it.
Comments
|
Categories
All
Archives
May 2020
|