Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restart/reuse a recurring Task?

I have a long-running Task that I've implemented using the Task Parallel Library. When the Task starts, I grab snapshots of several input values and collections then perform various operations using that information. If any of those values or collections change while the Task is running, I'd like to have the Task run again immediately upon completion. Should I be creating a new Task or is there a way to reuse the existing Task? What's the best way to start the second iteration?

like image 860
SonOfPirate Avatar asked Feb 27 '12 13:02

SonOfPirate


People also ask

How do I create a recurring task?

Create a recurring taskClick Task, click the bottom part of the Task button and then click Recurring Task. In the Task Name box, type the recurring task's name. In the Duration box, add the duration of each occurrence of the task. In the Recurrence pattern section, click Daily, Weekly, Monthly, or Yearly.


1 Answers

Create a new task.

As http://msdn.microsoft.com/en-us/library/dd270682.aspx points out, trying to restart a running or completed Task is not supported. It is rarely a good idea to do something that normally throws an exception, and re-using a Task is one of those things.

like image 140
Kendall Frey Avatar answered Oct 19 '22 23:10

Kendall Frey