I am trying to achieve the display of an animated gif in a
windows
app. I had hoped that by displaying it in a webbrowser contro that it would always be animated.
Currently it is only animated when the
system is not busy however when the app is processing such as returning data the animation freezes. To prevent this wouldit be possible to get the webbrowser control to run in a different thread, and could this solve my problem?
Cross-thread
operation not valid: Control 'uctrlBusyDisplay' accessed from a thread other than the thread it was created on.
public uctrlBusyDisplay()
{
InitializeComponent();
Thread t = new Thread(new
ThreadStart(DoIt));
t.SetApartmentState(ApartmentState.STA);
t.Start();
} private void
DoIt() {
WebBrowser wb = new
WebBrowser();
wb.Location = new Point(20,
10);
wb.Navigate("www.google.co.uk");
this.Controls.Add(wb);
}
|
The error seems to occur when I try and add the webbrowser control to the usercontrol.