Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2334
Grid freezing with animated gif in row selector
posted
My grid is bound to a List of my custom objects. On BeforeRowExpanded event I asynchronously fetch the child rows of the given row. While this async operation is happening I add an animated gif to the row selector of the given row to show that it is loading. When the async operation comes back I add the child collection to the appropriate listobject and reset the row selector image. This works about 50% of the time. the other 50% of the time the grid freezes and causes my app to die. Here is my code:

When I put a break point on the ImageAnimator.Stop line the app never freezes. This makes me wonder if it is a timing issue. I realize this is out of the box functionality but if anybody has an idea what could be happening I appreciate it.

public void SetRowLoading(UltraGridRow row, bool loading)
{
if (loading)
{
row.RowSelectorAppearance.Image = Properties.Resources.loading_small;
ImageAnimator.Animate((Image)row.RowSelectorAppearance.Image, new EventHandler(image_onFrameChange));
}
else
{
if (row != null && row.RowSelectorAppearance.Image != null)
{
ImageAnimator.StopAnimate((Image)row.RowSelectorAppearance.Image, new EventHandler(image_onFrameChange));
row.RowSelectorAppearance.ResetImage();
}
}
}


private void image_onFrameChange(object sender, EventArgs e)
{
if (_gridBlotter.InvokeRequired)
{
_gridBlotter.Invoke(new EventHandler(image_onFrameChange), new object[ { sender, e });
}
else
{
_gridBlotter.Invalidate(true);
ImageAnimator.UpdateFrames((Image)sender);
}
}

Thanks.

Drew
AnimatedGifSample.zip
Parents
No Data
Reply
  • 469350
    Offline posted

    Hi Drew,

    I doubt this has anything to do with the grid specifically. It's probably a threading issue. You should search the forum, there are several posts here about the dangers of using multiple threads with non-thread-safe UI controls. 

Children
No Data