mardi 22 mars 2016

C# Threading.Timer not always triggering when in a windows Service Task

Folks, I am implementing a routine in a Windows service .NET based, and am using a Threading.Timer task within

protected override void OnStart(string[] args)
{
   base.OnStart(args);
   _startupTask = Task.Factory.StartNew(StartupAction, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default);
}

in my StartupAction i am defning a Threading.Timer as follows:

private void StartupAction()
{ 
    System.Threading.Timer infamousTimer;
    infamousTimer = new System.Threading.Timer(new TimerCallback(runMeEveryHour), null, new TimeSpan(0), new TimeSpan(1, 0, 0));
}

One would think that this is a no brainer, but for some reason it is not always working (works on some PCs but not on others).

Would anyone know what would be the culprit or the environment dependency?

Thanks



C# Threading.Timer not always triggering when in a windows Service Task

Aucun commentaire:

Enregistrer un commentaire