I have an Azure Worker Role that has three types of processes:
Task1 and Task2 run indefinitely and sleep if their respective queues are empty.
My code looks like this:
SpawnJavaProcesses();
Task.Factory.StartNew(Task1);
Task.Factory.StartNew(Task2);
while(true)
{
//do some trivial sporadic work
Thread.Sleep(60*1000);
}
My questions:
If you have a few threads that are long running it would be best to use the LongRunning option. By choosing this option you'll be running in a thread outside of the thread pool. This is also something which was explained by Stephen Toub (from the Parallel Extensions team):
It's not a specific length per se. If you're generating a lot of tasks, LongRunning is not appropriate for them. If you're generating one or two tasks that will persist for quite some time relative to the lifetime of your application, then LongRunning is something to consider.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With