I want to schedule multiple work items to a single task, i.e. a single task should perform a task one after another. I know about .continuewith() functionality of tasks. My problem has two parts:
The first problem is that I also want to schedule priority to that task, I am using the scheduler suggested by romkyn in this post.
Is there any way that the same task should perform multiple works under the same priority level?
I am generating over a 100 tasks and schedule them with randomly assigned priority level, i.e. lowerst, above normal...highest.
During the generation and execution phase, how am I supposed to (a)know and (b)cancel the task which is executing using the taskcancellationtoken, if a task with higher priority level is generated and cannot wait?
For now, I am using a simple for loop and taskfactory to generate tasks.
Task t = Task.Factory.StartNew(() =>
{
//perform work1 here
}, ct, TaskCreationOptions.None, PriorityScheduler.Lowest);