Restart completed task

I have a task that runs periodically against the background of my application. When I run it for the first time, everything is fine, and the task ends perfectly. But the second time and after that, whenever I use task.Start(), it throws an exception:

An unhandled exception of type "System.InvalidOperationException" occurred in the mscorlib.dll file. Additional information: the start cannot be called upon the completed task.

I am sure that my task has been completed to the end. What should I do to run the task periodically?

+4
source share
2 answers

( )

  • : ?

. "", "" "": "" . " " "" . Start , , Task , Start ... .

.. , . , , .
, , TaskStatus.RanToCompletion

+8

System.Threading.Timer, . , , .. , , - ( , ).

+2

Source: https://habr.com/ru/post/1548697/


All Articles