Form Visibility Issue VB.NET 2003

  • Thread starter Thread starter Sid Price
  • Start date Start date
S

Sid Price

Hello,

I am having a problem with a windows form when controlling its visibility.
My application has a form that displays a timing function. Normally the
timing form is hidden. An object has a timer that causes some processing to
happen and at certain times it is required to make the timing display
visible. To do this it calls a delegate to request that the form be
displayed. Up until this point the hidden form is being upated by the same
delegate with time information, but it is hidden.

When the show event happens the outline of the form appears and the
application becomes non-responsive to any future requests to hide or display
the form.

This appears like a threading issue, but as I understand it as long as the
timing form is being called from the timer thread through "Invoke", which it
is, it should work. Any suggestions please.

Thank you,
Sid.
 
When the show event happens the outline of the form appears and the
application becomes non-responsive to any future requests to hide or
display the form.

This appears like a threading issue, but as I understand it as long as
the timing form is being called from the timer thread through
"Invoke", which it is, it should work. Any suggestions please.

You might want to try BeginInvoke instead.

So althought invoke is correct - if the invoked function takes a long time
to run, it'll still block the UI.

Also any sub calls? They should all be checked for InvokeRequired as well.

Oh lastly - were all objects created on same thread? If not - you'll need
to check Object.InvokeRequired on each object - so that the call is
marhsalled to the right thread.
 
Spam Catcher said:
You might want to try BeginInvoke instead.

So althought invoke is correct - if the invoked function takes a long time
to run, it'll still block the UI.

Also any sub calls? They should all be checked for InvokeRequired as well.

Oh lastly - were all objects created on same thread? If not - you'll need
to check Object.InvokeRequired on each object - so that the call is
marhsalled to the right thread.

Many thanks for your note (whoever you are :o)) I implemented the
"InvokeRequired" check and followed it with the "BeginInvoke" and this seems
to have resolved the problem.

Again, many thanks,.
Sid.
 
I have a little more information on this issue if anyone has any ideas I
would much appreciate hearing them:

The problem occurs under the following two conditions.

1. The dipslay form is hidden and needs to be shown, AND
2. The call to show the display form is NOT in the thread that
instantiated the form.

Note that the following code is used to figure out if the call needs to use
BeginInvoke or not:

If mDisplayWindow.InvokeRequired = True Then

mDisplayWindow.BeginInvoke(New DVisible(AddressOf Delegate_Visible), New
Object() {DisplayVisible})

Else

mDisplayWindow.Visible = DisplayVisible

End If

I have checked that when the request to show the form comes from the thread
BeginInvoke is being called regardless of the form being currently visible
or not.

Thank you,

Sid.
 

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

Back
Top