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?
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?
However I am getting hte error
Cross-thread operation not valid: Control 'uctrlBusyDisplay' accessed from a thread other than the thread it was created on.
The error seems to occur when I try and add the webbrowser control to the usercontrol.
|
this.Controls.Add(wb);
|
I have triebut still get the error as I dont really understand the method.
Also jumping ahead to when I have achieved this when I have added the control will the webbrowser still control be running in its own thread when it is added to the main form?
Sam HobbsPosted Sep 10, 2010, 5:20 PM
James WilcockPosted Sep 10, 2010, 4:15 AM
Obj controlFactors is a UserControl which I have added to my form, it is the control upon which the animation is shown.
Anyway I guess I have digressed now from the animation problem and all I want to do now is execute my get data method (which takes a parameter) in a new thread.
Or perhaps using a progress bar I could use this
http://www.codeguru.com/columns/vb/article.php/c10755
If I could convert to C#
Right now its not liking the delegate.
Sam HobbsPosted Sep 9, 2010, 12:21 PM
Sam HobbsPosted Sep 9, 2010, 12:15 PM
I think the ProgressBar is capable of showing animation; have you looked at that?
Also, you should use the BackgroundWorker class; it is designed to be easier to use.
James WilcockPosted Sep 9, 2010, 12:14 PM
James WilcockPosted Sep 9, 2010, 12:08 PM
I think it is most likely because i am trying to pass a parameter through to the method im trying to invoke in the new thread, which it doesnt seem to like.
James WilcockPosted Sep 9, 2010, 10:58 AM
I want the animation (the browser control) to be invisible. When the user presses the button to return some data I will make the animation visible.
I think at this point I will strat a new thread to call the getdata method
Once the getdata method has completed I will make the webbrowser control invisible again.
So I think I am looking at some thing like this.
Sam HobbsPosted Sep 9, 2010, 10:41 AM
I don't think you have specified whether the animation changes due to time or due to progress.
James WilcockPosted Sep 9, 2010, 10:21 AM
In terms of threading do I need to kill the threads when the data has been returned? If the user presses the get data button numerous times is it risky to be spawning lots of new threads?
James WilcockPosted Sep 9, 2010, 3:55 AM
Maybe there is a better way to achieve this?
Sam HobbsPosted Sep 9, 2010, 2:45 AM