Welcome tag moderator AKA Unofficial DEV cheerleader. While most of my friends are found on SnapChat or Tic-Toc, you can find me here. And I OOP, but I’m not a VSCO girl.
Ahh yes, the timer's TimerCallback method signature needed to be void DoWork(object state) hence needing another method call that uses async Task accepting a CancellationToken.
But looking at it again I think that DoWorkAsync and RunJobAsync could just be the one method.
I'll take another look later and will try and explain more in another blog post.
Welcome tag moderator AKA Unofficial DEV cheerleader. While most of my friends are found on SnapChat or Tic-Toc, you can find me here. And I OOP, but I’m not a VSCO girl.
Hi Katie,
Take a look at this. hitting ctrl-c while its running or in the 5-second DoWork method will cancel gracefully and hopefully do what you want.
I plan to blog about it in more detail later but this should help.
Gist here
gist.github.com/solrevdev/f28ab813...
Thanks John. I see now the running timer callback is buried several levels down. Makes things a bit more complex, but I understand what you did.
Ahh yes, the timer's TimerCallback method signature needed to be
void DoWork(object state)
hence needing another method call that uses async Task accepting a CancellationToken.But looking at it again I think that
DoWorkAsync
andRunJobAsync
could just be the one method.I'll take another look later and will try and explain more in another blog post.
Great! Looking forward to it.