How can the ray just run a method once after a certain time?

That is, you need to call the method after a specified time.

Can this be done via Task.Delay() ?

    1 answer 1

    If your method is asynchronous, then yes, you can use Task.Delay() :

     public async Task MethodWithDelayAsync(int milliseconds) { await Task.Delay(milliseconds); // остальной код } 

    If the code is synchronous and you do not want to use async / await, then you can use Timer from System.Threading : set a delay and a single run.

     new Timer(MyMethod, null, 1000, Timeout.Infinite); 

    https://msdn.microsoft.com/ru-ru/library/system.threading.timer.timer(v=vs.110).aspx