Home All Groups Group Topic Archive Search About

VB.NET Screen Stops Refreshing After Losing Focus??

Author
1 Jun 2006 8:29 PM
Chris Moore
I have a .NET form where I am updating a progress bar & counter.  As long
as the form never loses focus, everything on the form refreshs fine. But If
I open another window (like Windows Explorer) and then re-select my .net
form, thos fields no longer refresh.  Why and ho wdo I make it start
refreshing again?

Thanks

Author
1 Jun 2006 8:41 PM
Mehdi
On Thu, 01 Jun 2006 13:29:45 -0700, Chris Moore wrote:

> I have a .NET form where I am updating a progress bar & counter.  As long
> as the form never loses focus, everything on the form refreshs fine. But If
> I open another window (like Windows Explorer) and then re-select my .net
> form, thos fields no longer refresh.  Why and ho wdo I make it start
> refreshing again?

It sounds like you're accessing some of your UI controls from a worker
thread (the progress bar and the counter probably). UI controls must be
accessed from the UI thread only. If you have to access them from a worker
thread, use Control.Invoke or Control.BeginInvoke to marshall the call to
the UI thread.
Author
1 Jun 2006 8:47 PM
Chris Moore
Mehdi <vio***@REMOVEME.gmail.com> wrote in
I have no idea what you just said, sorry.  What I have is 1 form with a
button, progress bar & label on it.  When I run it, I press the button
that then calls a procedure (that is in the form) to process some records
and update the controls.

What am I missing or not understanding?

Thanks

Show quoteHide quote
news:heawgmahabxx.zuvwiijdairp.dlg@40tude.net:

> On Thu, 01 Jun 2006 13:29:45 -0700, Chris Moore wrote:
>
>> I have a .NET form where I am updating a progress bar & counter.  As
>> long as the form never loses focus, everything on the form refreshs
>> fine. But If I open another window (like Windows Explorer) and then
>> re-select my .net form, thos fields no longer refresh.  Why and ho
>> wdo I make it start refreshing again?
>
> It sounds like you're accessing some of your UI controls from a worker
> thread (the progress bar and the counter probably). UI controls must
> be accessed from the UI thread only. If you have to access them from a
> worker thread, use Control.Invoke or Control.BeginInvoke to marshall
> the call to the UI thread.
>
Author
1 Jun 2006 9:48 PM
tommaso.gastaldi
try putting

        Application.DoEvents()

within the loop

-tom

Chris Moore ha scritto:

Show quoteHide quote
> Mehdi <vio***@REMOVEME.gmail.com> wrote in
> I have no idea what you just said, sorry.  What I have is 1 form with a
> button, progress bar & label on it.  When I run it, I press the button
> that then calls a procedure (that is in the form) to process some records
> and update the controls.
>
> What am I missing or not understanding?
>
> Thanks
>
> news:heawgmahabxx.zuvwiijdairp.dlg@40tude.net:
>
> > On Thu, 01 Jun 2006 13:29:45 -0700, Chris Moore wrote:
> >
> >> I have a .NET form where I am updating a progress bar & counter.  As
> >> long as the form never loses focus, everything on the form refreshs
> >> fine. But If I open another window (like Windows Explorer) and then
> >> re-select my .net form, thos fields no longer refresh.  Why and ho
> >> wdo I make it start refreshing again?
> >
> > It sounds like you're accessing some of your UI controls from a worker
> > thread (the progress bar and the counter probably). UI controls must
> > be accessed from the UI thread only. If you have to access them from a
> > worker thread, use Control.Invoke or Control.BeginInvoke to marshall
> > the call to the UI thread.
> >
Author
1 Jun 2006 10:09 PM
ods
That appears to have corrected it.

Thanks.


tommaso.gasta***@uniroma1.it wrote in
Show quoteHide quote
news:1149198501.107577.129780@y43g2000cwc.googlegroups.com:

> try putting
>
>         Application.DoEvents()
>
> within the loop
>
> -tom
>
> Chris Moore ha scritto:
>
>> Mehdi <vio***@REMOVEME.gmail.com> wrote in
>> I have no idea what you just said, sorry.  What I have is 1 form with
>> a button, progress bar & label on it.  When I run it, I press the
>> button that then calls a procedure (that is in the form) to process
>> some records and update the controls.
>>
>> What am I missing or not understanding?
>>
>> Thanks
>>
>> news:heawgmahabxx.zuvwiijdairp.dlg@40tude.net:
>>
>> > On Thu, 01 Jun 2006 13:29:45 -0700, Chris Moore wrote:
>> >
>> >> I have a .NET form where I am updating a progress bar & counter.
>> >> As long as the form never loses focus, everything on the form
>> >> refreshs fine. But If I open another window (like Windows
>> >> Explorer) and then re-select my .net form, thos fields no longer
>> >> refresh.  Why and ho wdo I make it start refreshing again?
>> >
>> > It sounds like you're accessing some of your UI controls from a
>> > worker thread (the progress bar and the counter probably). UI
>> > controls must be accessed from the UI thread only. If you have to
>> > access them from a worker thread, use Control.Invoke or
>> > Control.BeginInvoke to marshall the call to the UI thread.
>> >
>
>
Author
4 Jun 2006 3:15 PM
tommaso.gastaldi
good.
Applications are like humans, sometimes they need to breath   :)

-tom

ods ha scritto:

Show quoteHide quote
> That appears to have corrected it.
>
> Thanks.
>
>
> tommaso.gasta***@uniroma1.it wrote in
> news:1149198501.107577.129780@y43g2000cwc.googlegroups.com:
>
> > try putting
> >
> >         Application.DoEvents()
> >
> > within the loop
> >
> > -tom
> >
> > Chris Moore ha scritto:
> >
> >> Mehdi <vio***@REMOVEME.gmail.com> wrote in
> >> I have no idea what you just said, sorry.  What I have is 1 form with
> >> a button, progress bar & label on it.  When I run it, I press the
> >> button that then calls a procedure (that is in the form) to process
> >> some records and update the controls.
> >>
> >> What am I missing or not understanding?
> >>
> >> Thanks
> >>
> >> news:heawgmahabxx.zuvwiijdairp.dlg@40tude.net:
> >>
> >> > On Thu, 01 Jun 2006 13:29:45 -0700, Chris Moore wrote:
> >> >
> >> >> I have a .NET form where I am updating a progress bar & counter.
> >> >> As long as the form never loses focus, everything on the form
> >> >> refreshs fine. But If I open another window (like Windows
> >> >> Explorer) and then re-select my .net form, thos fields no longer
> >> >> refresh.  Why and ho wdo I make it start refreshing again?
> >> >
> >> > It sounds like you're accessing some of your UI controls from a
> >> > worker thread (the progress bar and the counter probably). UI
> >> > controls must be accessed from the UI thread only. If you have to
> >> > access them from a worker thread, use Control.Invoke or
> >> > Control.BeginInvoke to marshall the call to the UI thread.
> >> >
> >
> >
Author
27 Jun 2006 5:23 PM
OC
Good grief! I've Googled high and low for this answer. I

've been developing Web apps for so long I'd forgotten how to do this.
I know this is not the way I used to do it but this is far easier.
Thank you so much!

-Olice