Home All Groups Group Topic Archive Search About

Form Visibility Issue VB.NET 2003

Author
21 Apr 2006 9:10 PM
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.

Author
21 Apr 2006 9:51 PM
Spam Catcher
"Sid Price" <s**@nowhere.com> wrote in
news:uCplUgYZGHA.3400@TK2MSFTNGP02.phx.gbl:

> 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.
Author
22 Apr 2006 12:45 AM
Sid Price
Show quote Hide quote
"Spam Catcher" <spamhoneypot@rogers.com> wrote in message
news:Xns97ACB58D1BAACusenethoneypotrogers@127.0.0.1...
> "Sid Price" <s**@nowhere.com> wrote in
> news:uCplUgYZGHA.3400@TK2MSFTNGP02.phx.gbl:
>
>> 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.

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.
Author
24 Apr 2006 3:30 PM
Sid Price
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.

Show quoteHide quote
"Spam Catcher" <spamhoneypot@rogers.com> wrote in message
news:Xns97ACB58D1BAACusenethoneypotrogers@127.0.0.1...
> "Sid Price" <s**@nowhere.com> wrote in
> news:uCplUgYZGHA.3400@TK2MSFTNGP02.phx.gbl:
>
>> 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.