My Question is more about getting to the same destination, but there must be another way. Right now im creating a DateTime
and compare that to another DateTime
and check, if the time difference I set up might be right. So far so good but I just can't accept that I create a new propertie everytime the loop will get into that code.
Is there any possible way to get to the same destination, but in some kind of more effective way?
I got you guys some example code here:
private void RunService()
{
// Runs as long as the service didn't got a stop call.
while (!SetStop)
{
//Get MinutesToWait
this.MinutesToWait = 5;
DateTime CheckRunTime = this.LastRun;
CheckRunTime.AddMinutes(this.MinutesToWait);
if (DateTime.Now >= CheckRunTime)
{
// Imagine some good and smart and totally runnable code?
}
}
}