Che

Che

  • NA
  • 6
  • 0

Loading form thread

Nov 10 2009 9:03 PM
Hi All, I am having a problem trying to do something that I would think be a simple task. I am using a 3rd party control that is much like a standard progress bar (only I don't need a delegate to update the progress of the bar). I have a form that contains this "progress bar" and want to show it at different times during my windows application. I have tried a number of different ways of doing this, each having it's own problem. The following are the different methods and issues I have had: 1. Create an instance of the for and do form.Show() and form.Close() when the operation is ended; the problem with this is that the loading form does not show properly, it just appears as a black rectangle. 2. Create a class with a static thread, the function that the thread uses when created creates an instance of the loading form. On thread.Start() it will show the loading form. When the operation is ended I then call thread.Abort(). The next time I call thread.Start I create a new instance of the static thread; the problem with this is occasionally I get a "Thread was being aborted" exception 3. Create a class with a static thread, the function that the thread uses when created creates an instance of the loading form. On thread.Start() it will show the loading form. Thread.Suspend() the thread when the operation is complete, then do a thread.Restart() when I want to see the loading screen again; The issue that occurs here is that the loading form just freezes and is shown like that (as I cannot do form.Close() or form.Hide()) 4. I did try other work around for thread.suspend()/thread.Restart() as I read that these are as bad as using thread.Abort() 5. I used something like a backgroundWorder thing as well, I can't remember exactly what it did, but it didn't work either. 6. The latest I have tried is to put the loading bar on a panel that is used in the Main win app form. This does not appear when I set it's visibility to true, and if I default it's visibility to true then it will not disappear. Any thoughts would be great, even better would be a solution that someone has already done. The ideal solution would be the thread one as it looks nice and is simple to implement. The thread is doing nothing complicated, only showing a form and making that form hide or close when it is finished. I want to keep all this in one class as it keeps the code nice and neat, instead of having to create a thread in each class every time I need to start up a loading screen. I'm not normally a praying man, but if you're up there, please save me, Superman!

Answers (2)