I want to have my UI update every 30ms so I have some images animate while things are being processed with some async tasks.
No matter what I do or which timer I use (System.Threading.Timer or System.Windows.Forms.Timer) when things get busy the most frequent my timer is updated is about 1 second. I understand Windows is not a real-time operating system, so I won't be able to get it perfectly on 30 ms, but there's got to be some way of making this timer function have more priority and trigger more frequently!
static DateTime s_mLastTick = DateTime.Now;
mAnimationTimer = new System.Threading.Timer((state) =>
{
DateTime now = DateTime.Now;
Debug.WriteLine("MS since that run: " + now.Subtract(s_mLastTick).TotalMilliseconds);
s_mLastTick = now;
this.InvokeIfRequired(() =>
{
AnimateImages();
});
}, null, 0, 30); // doesn't matter what I set this 30 to, the best log output I can get is ~1000 ms during intense computation
There's got to be a way of doing this.. any ideas?
Thanks!