Reputation: 2937
I am using a TaskFactory to manage my program's tasks. I would like to add a task to the queue that will start running after X minutes. Can it be done using .Net's standard tools or do I need to use a custom library for that.
Thanks
Upvotes: 1
Views: 1862
Reputation:
Yes this can be quite easily achieved. Look into some articles of basic multi-threading to ensure your UI is still responsive when scheduling/running these tasks. As has already been mentioned - the Timer control will do the trick.
The Programmers Heaven EBook on C#'s multi-threading section has enough in it to do what you want with regards to the multi-threading.
Upvotes: 2
Reputation: 24383
You could create a single-shot Timer
that creates your Task
when it fires. This means you won't be blocking a thread while you are waiting.
If you are writing a scheduler, you might want to look at Quartz.NET
Upvotes: 1
Reputation: 572
If you objective is to run something after a while you could use the Timer
Start the Timer
, when the timer has elapsed, stop the Timer
.
Upvotes: 1