I have a Little Problem with timers in my Project.
I use multiple timers (System.Threading.Timer).
Some of the TimerCallback methods are short running, some are long running.
Now I found out that as long as the long running timer callback is executed, no other timer is fired.
Is this normal behaviour in NETMF or is there a maximum limit of timer callbacks which are executed in parallel.
For testing issues I started the long running operation in a seperate thread from the original timer callback.
After this change the short running timer is executed normally
longRunningTimer = new Timer(LongRunningCallback, null, 30000, 30000);
shortRunningTimer = new Timer(ShortRunningCallback, null, 1000, 1000);
...
void LongRunningCallback(object state)
{
// this is a longer operation which blocks other timers
Thread.Sleep(20000);
}
void ShortRunningCallback(object state)
{
// I'm done quickly
Thread.Sleep(50);
}
If i Change the LongRunningCallback to
void LongRunningCallback(object state)
{
ThreadPool.QueueUserWorkItem(_ =>
{
// this is a longer operation which does not blocks other timers
Thread.Sleep(20000);
});
}
It works fine and the 1000ms Timer is fired all the time.
I’m using the latest SDK 4.2.11 on a G120
And just to mention: I’m not sure if this is a general problem or if this just happens in my quite huge multi threaded application.