C# task repeat every x count


C# task repeat every x count



There are currently many solutions on StackOverflow using C# task to repeatedly do some work every x time interval. I would like to do it repeatedly to say every 100 counts of a counter. This counter is not time-based but is actually a number of values stored into an array for example. Is there any tutorial which could give an idea on how to implement this?





Gimme teh tutorialz is not a valid question for stackoverflowz
– TheGeneral
Jul 2 at 10:12






Try using TaskScheduler Class (msdn.microsoft.com/en-us/library/…).
– Afonso
Jul 2 at 10:18





@Afonso This is terrible advice. The name "TaskScheduler" sounds good, but it actually doesn't do what you might think it does. This is used for scheduling tasks internally to thread pool. There is absolutely no reason to call this class.
– FCin
Jul 2 at 10:36






@TheGeneral Maybe not tutorial but some direction. I feel that the Task class in C# is very useful especially for data acquisition but instead of time based, a counter based would be also equally useful if we wanted to do analysis say every 1000 samples regardless of how long the data took.
– user990639
Jul 2 at 14:23




1 Answer
1



Something like this ?


if (i%100 == 0)
{
// do something
}






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Rothschild family

Cinema of Italy