If you load each frame into an ImageList, you can use a refresh loop for each frame. Example:
bool runThrobber = true;
private void AnimateThrobber(TreeNode animatedNode)
{
BackgroundWorker bg = new BackgroundWorker();
bg.DoWork += new DoWorkEventHandler(delegate
{
while (runThrobber)
{
this.Invoke((MethodInvoker)delegate
{
animatedNode.SelectedImageIndex++;
if (animatedNode.SelectedImageIndex >= imageList1.Images.Count) > animatedNode.SelectedImageIndex = 0;
});
Thread.Sleep(100);
}
});
bg.RunWorkerAsync();
}
Obviously, there are more than a few ways to implement this, but here is the main idea.
source
share