I'm really loving the TPL. Simply calling Task.Factory.StartNew()
and not worrying about anything, is quite amazing.
But, is it possible to have multiple Factories running on the same thread? Basically, I have would like to have two different queues, executing different types of tasks. One queue handles tasks of type A while the second queue handles tasks of type B.
If queue A has nothing to do, it should ignore tasks in queue B and vice versa.
Is this possible to do, without making my own queues, or running multiple threads for the factories?
To clarify what I want to do.
I read data from a network device. I want to do two things with this data, totally independent from each other.
- I want to log to a database.
- I want to send to another device over network.
Sometimes the database log will take a while, and I don't want the network send to be delayed because of this.