Timeline for Action queue in .NET 3.5
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 15, 2011 at 15:21 | comment | added | rotman | New version above. | |
Dec 15, 2011 at 13:04 | comment | added | vgru |
@rotman: ok, my answer was based on your first example. If you do need to create this list from several places, using a separate class might make it more explicit. But you should then consider suggestions made by Slade and Jesse: I would not expose the mutable list to the outside world, if there is a chance that it may be iterated on a separate thread. The simplest way would be to change the list into a Queue , make it private, and expose a public Add method which should lock while enqueuing.
|
|
Dec 14, 2011 at 13:46 | comment | added | rotman |
But wait... I need to enqueue some actions from different places and in different moments and then start them from another so the code you provided is not enough. Of course, I can build a queue and process it using ThreadPool but don't you think that using ActionQueue is better idea?
|
|
Dec 14, 2011 at 13:39 | comment | added | rotman | Oh, sorry - now I see that you put it in a single lambda :) You are right then. Thank you. | |
Dec 14, 2011 at 13:30 | comment | added | rotman |
And I thought that ThreadPool is used rather to do some work in parallel. Am I wrong? Does it execute actions one by one?
|
|
Dec 14, 2011 at 13:26 | comment | added | rotman | I think that justification in using it is the possibility to reuse it and expand in the future. You think that isn't enough? :) | |
Dec 14, 2011 at 11:52 | history | answered | vgru | CC BY-SA 3.0 |