I want to write an application that needs a Tasks queue. I should be able to add Tasks into this queue and these tasks can finish asynchronously (and should be removable from this queue, once they are complete)
The datastructure should also make it possible to get the information about any task within the Queue, provided a unique queue-position-identifier.
The data-structure should also provide the list of items in the queue anytime.
A LINQ interface to manage this queue will also be desirable.
Since this is a ver开发者_Python百科y common requirement for many applications (atleast in my personal observation), I want to know if there are any standard datastructures that are available as part of the c# library, instead of I writing something from the scratch.
Any pointers ?
Seems to me you are conflating the data structure and the asynch task that it is designed to track. Are you sure they need to be the same thing?
Does ThreadPool.QueueUserWorkItem not satisfy for running asynch tasks? You can maintain your own structure derived from List<TaskStatus>
or HashSet<TaskStatus>
to keep track of the results, and you can provide convenience methods to clear completed items, retrieve pending items, and so on.
精彩评论