I want to execute some code on each second. The code I am using now is:
Task.Run((Action)ExecuteSomething);
And ExecuteSomething()
is defined as below:
private void ExecuteSomething()
{
Task.Delay(1000).ContinueWith(
t =>
{
//Do something.
ExecuteSomething();
});
}
Does this method block a thread? Or should I use Timer
class in C#? And it seems Timer also dedicates a separate thread for execution (?)