internal void Animator()
{
try {
while (true) {
m_animationContinue.WaitOne();
m_animationContinue.Reset();
double animateFrom = Opacity;
double animateTo = m_animateTo;
if (m_animateTo == 1) {
Invoke((MethodInvoker)delegate() {
Visible = true;
});
}
int startMSec = System.Environment.TickCount;
while (true) {
int elapsedMSec = System.Environment.TickCount - startMSec;
double percentComplete = (Math.Min(elapsedMSec, s_animationDurationMSec) / (double)s_animationDurationMSec);
try {
Invoke((MethodInvoker)delegate() {
Opacity = animateFrom + (animateTo - animateFrom) * percentComplete;
});
} catch (Exception) { }
if (elapsedMSec >= s_animationDurationMSec) {
break;
}
Thread.Sleep((int)(1000 / 33d)); // 33 fps
}
if (m_animateTo == 0) {
Invoke((MethodInvoker)delegate() {
Visible = false;
});
}
}
} catch (Exception) {
//System.Diagnostics.Debug.WriteLine("Animator ended!");
}
}