Progress Bar Window Not Drawing

  • Thread starter Thread starter bennett.sean
  • Start date Start date
B

bennett.sean

Hi,

I've tried a number of different things including the use of threads
and timers, but can't come up with the solution yet.

The issue is this: launch a window with an animation or progress bar
that changes. While this "progress window" is being animated, launch
the actual window. Finally close the "progress window".

The problem is, the "progress window" does not render the gui until the
second window is done loading.

Any links or hints are appreciated.

Thanks,

Sean.
 
You need to add some Application.DoEvents calls into your load code for the
second window. All of this processing is occuring on a single thread of
execution. The timer events will not be received by the progress bar window
unless periodically you give up execution by calling Application.DoEvents.
Otherwise the only code that gets a chance to run is the code that is loading
your form.
 
DoEvents does do the trick... but the problem is that the code blocking
the message queue is in the InitializeComponent Sub of a form... so I
can't exactly put Application.DoEvents every 10 lines in
InitializeComponent.

There must be an easy solution. Help anyone?

Thanks,

Sean
 
I found out what was wrong.

Creating a thread was the right way to go but some additional
properties of that thread had to be set.

This is what made it work:

Dim t As System.Threading.Thread
t = New System.Threading.Thread(AddressOf progressThreadStart)
t.IsBackground = True
t.ApartmentState = Threading.ApartmentState.STA
t.Start()

the IsBackground and ApartmentState lines did the trick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top