-3
public Data GetData()
{
    ...
    updateCache();
}

public void timer()
{
    //I would like to call GetData() every minute
}

I would like to trigger GetData() every minute and update a cache.

What is the best way to do this in C#?

Anatoly
  • 1,868
  • 2
  • 22
  • 43

1 Answers1

6

Timer is the simplest and easiest way.

blas3nik
  • 1,351
  • 11
  • 21
  • Or use a background thread for it. http://stackoverflow.com/questions/20830346/recurring-background-task – marcel Dec 10 '15 at 14:45
  • There are at least a million ways of solving this, some are better for some scenarios - I assumed OP wanted to have the simplest and shortest one, and in my opinion that is the Timer. But sure enough using a thread is easy as well. – blas3nik Dec 10 '15 at 14:50