Is there any way to prioratize a task in TPL.
-
i'm new to TPL and , trying to achieve prioritization in tasks using TPL. which means for example , i have to start two tasks parallel (t1 and t2) but i need to give the priority to t1 means both are having messages to deliver but t1 got the highest priority messages so i need to send them before t2 messages. is this possible, thanx in advance
-
i'm new to TPL and , trying to achieve prioritization in tasks using TPL. which means for example , i have to start two tasks parallel (t1 and t2) but i need to give the priority to t1 means both are having messages to deliver but t1 got the highest priority messages so i need to send them before t2 messages. is this possible, thanx in advance
About the only option you have is in the Task.CreationOptions property. The TaskCreationOptions enum can tell the scheduler to PreferFairness, meaning that tasks created earlier tend to run sooner than tasks created later. Other than that, you'd have to setup some communication between tasks so they can work out whos going to send messages first. But, if you have to schedule messages being sent, that sounds like a seperate thread that should maintain it's own message scheduler. Your other tasks would have to submit their messages (with a some priority token) to the scheduler to be sent out.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak