
Originally Posted by
vinayppatil
That's the question. How do i achieve this? How do i know i have last few seconds remaining? Do OS notifies me? if yes how? if no, shall i run my own timer and what's the best way to run a timer C#?
As Wizard_hu_ stated before, you need to store the timespan on the beginning of your OnInvoke method,
Code:
DateTime onInvokeStart = DateTime.Now;
while((DateTime.Now-onInvokeStart).TotalSeconds <= 23) // DateTime.Now-onInvokeStart will return a TimeSpan type
{
// do you work
}
NotifyComplete();