Is it safe to use OnTimer like this?
25 Feb 2015, 22:50
protected override void OnStart()
{
Timer.Start(TimeSpan.FromMilliseconds(1));
}
protected override void OnTick()
{
Timer.Stop();
//Do some calculations
Timer.Start(TimeSpan.FromMilliseconds(1));
}
protected override void OnTimer()
{
OnTick();
}
protected override void OnStop()
{
Timer.Stop();
}
Would the code above work without risk causing cAlgo to crash?
Timer is from cAlgo.API.
Appreciate any and all input.
Aim
Replies
AimHigher
27 Feb 2015, 23:26
Thank you. The new Timer and RefreshData() have increased the value (to me) of your platform tremendously.
Regards,
Aim
@AimHigher

Spotware
27 Feb 2015, 14:50
Yes, it is safe. cAlgo invokes OnTimer method in the same thread as OnStart, OnTick and other methods. You can use cAlgo.API.Timer without multi-threading issues.
@Spotware