DoEvents is inconsistant why?

  • Thread starter Thread starter james
  • Start date Start date
J

james

In my app I load a control into a Panel, and then I fetch a large amount of
data from the database. I am trying to get the Control to display
immediately instead of after the Fetch completes. So I added a
control.Refresh() and control.Update() but none of that seemed to do the
trick. So as a test I added Application.DoEvents() just before the Fetch
hoping that would force the screen to re-paint, and what I find out is that
I get two different results. When Debugging and stepping over the DoEvents,
my control immediatley draws itself on the screen as I want it to, BUT, when
I actually run the app without debug stepping over the DoEvents, the screen
does NOT update until after the Fetch completes. So, are there any
suggestions as to how I can get the Refresh/Update/DoEvents to work as I
want?

thanks,

JIM
 
I cannot do that for several reasons. First I am not in control of the
framework that does the fetching, second, because of databinding, the thread
must be the same thread the WinForms run in or the controls and the data
will be out of synche and bad things will happen :-)

thanks,

JIM
 
Hi James,

Can you force the control to paint itself BEFORE the fetch (let it display
no data but be fully painted). Then, call the fetch method asynchronously
through BeginInvoke, and when the asynchronous call completes, bind the
returned dataset to the control and repaint it once again.
 
How?


Dmitriy Lapshin said:
Hi James,

Can you force the control to paint itself BEFORE the fetch (let it display
no data but be fully painted). Then, call the fetch method asynchronously
through BeginInvoke, and when the asynchronous call completes, bind the
returned dataset to the control and repaint it once again.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

james said:
I cannot do that for several reasons. First I am not in control of the
framework that does the fetching, second, because of databinding, the
thread must be the same thread the WinForms run in or the controls and the
data will be out of synche and bad things will happen :-)

thanks,

JIM
 
Cant you draw the form. Then start a timer for 10milliseconds which does the
fetch and binds the control.
Not perfect but would work.

Ciaran


james said:
How?


Dmitriy Lapshin said:
Hi James,

Can you force the control to paint itself BEFORE the fetch (let it
display no data but be fully painted). Then, call the fetch method
asynchronously through BeginInvoke, and when the asynchronous call
completes, bind the returned dataset to the control and repaint it once
again.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

james said:
I cannot do that for several reasons. First I am not in control of the
framework that does the fetching, second, because of databinding, the
thread must be the same thread the WinForms run in or the controls and
the data will be out of synche and bad things will happen :-)

thanks,

JIM


I would suggest threading the fetch.


In my app I load a control into a Panel, and then I fetch a large
amount
of
data from the database. I am trying to get the Control to display
immediately instead of after the Fetch completes. So I added a
control.Refresh() and control.Update() but none of that seemed to do
the
trick. So as a test I added Application.DoEvents() just before the
Fetch
hoping that would force the screen to re-paint, and what I find out is
that
I get two different results. When Debugging and stepping over the
DoEvents,
my control immediatley draws itself on the screen as I want it to,
BUT,
when
I actually run the app without debug stepping over the DoEvents, the
screen
does NOT update until after the Fetch completes. So, are there any
suggestions as to how I can get the Refresh/Update/DoEvents to work as
I
want?

thanks,

JIM
 
No, I can't. You see the Control I am placing onto My form does its own
fetching and databinding internally. All I do is instantiate it, and place
it into a Panel in my application. Once I place it on screen, I tell the
Window and the Control to Refresh so it will draw, then I tell the Control
to Start doing its job, which then initiates its internal fetch and display
of data. I fail to see why the Refresh/Update commmands refuse to do what
they state they do in the documentation.

thanks,

JIM


Ciaran said:
Cant you draw the form. Then start a timer for 10milliseconds which does
the fetch and binds the control.
Not perfect but would work.

Ciaran


james said:
How?


Dmitriy Lapshin said:
Hi James,

Can you force the control to paint itself BEFORE the fetch (let it
display no data but be fully painted). Then, call the fetch method
asynchronously through BeginInvoke, and when the asynchronous call
completes, bind the returned dataset to the control and repaint it once
again.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

I cannot do that for several reasons. First I am not in control of the
framework that does the fetching, second, because of databinding, the
thread must be the same thread the WinForms run in or the controls and
the data will be out of synche and bad things will happen :-)

thanks,

JIM


I would suggest threading the fetch.


In my app I load a control into a Panel, and then I fetch a large
amount
of
data from the database. I am trying to get the Control to display
immediately instead of after the Fetch completes. So I added a
control.Refresh() and control.Update() but none of that seemed to do
the
trick. So as a test I added Application.DoEvents() just before the
Fetch
hoping that would force the screen to re-paint, and what I find out
is
that
I get two different results. When Debugging and stepping over the
DoEvents,
my control immediatley draws itself on the screen as I want it to,
BUT,
when
I actually run the app without debug stepping over the DoEvents, the
screen
does NOT update until after the Fetch completes. So, are there any
suggestions as to how I can get the Refresh/Update/DoEvents to work
as I
want?

thanks,

JIM
 
Back
Top