How to reset a Task.Delay() after a event fired?
问题 I am trying to let some code fire after my FileSystemWatcher hasn't received any changes for more then 5 minutes. My current approach is to call a await Task.Delay(); after a change, hoping the user is done by then. This obviously is not the way to go. So my question: How to reset a Task.Delay() after a event fired? 回答1: You can't "reset" a Task.Delay , but you can reset a timer which makes it an ideal candidate to solve this problem. Here's an example: private System.Threading.Timer timer;