473,383 Members | 1,788 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

DoEvents is inconsistant why?

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
Nov 16 '05 #1
6 2802
I would suggest threading the fetch.
"james" <no****@hypercon.net> wrote in message
news:uB**************@TK2MSFTNGP14.phx.gbl...
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

Nov 16 '05 #2
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
"Wayne" <Me******@community.nospam> wrote in message
news:eP**************@TK2MSFTNGP12.phx.gbl...
I would suggest threading the fetch.
"james" <no****@hypercon.net> wrote in message
news:uB**************@TK2MSFTNGP14.phx.gbl...
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


Nov 16 '05 #3
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" <no****@hypercon.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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
"Wayne" <Me******@community.nospam> wrote in message
news:eP**************@TK2MSFTNGP12.phx.gbl...
I would suggest threading the fetch.
"james" <no****@hypercon.net> wrote in message
news:uB**************@TK2MSFTNGP14.phx.gbl...
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




Nov 16 '05 #4
How?
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:OQ**************@TK2MSFTNGP10.phx.gbl...
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" <no****@hypercon.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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
"Wayne" <Me******@community.nospam> wrote in message
news:eP**************@TK2MSFTNGP12.phx.gbl...
I would suggest threading the fetch.
"james" <no****@hypercon.net> wrote in message
news:uB**************@TK2MSFTNGP14.phx.gbl...
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


Nov 16 '05 #5
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" <no****@hypercon.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
How?
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:OQ**************@TK2MSFTNGP10.phx.gbl...
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" <no****@hypercon.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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
"Wayne" <Me******@community.nospam> wrote in message
news:eP**************@TK2MSFTNGP12.phx.gbl...
I would suggest threading the fetch.
"james" <no****@hypercon.net> wrote in message
news:uB**************@TK2MSFTNGP14.phx.gbl...
> 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
>
>


Nov 16 '05 #6
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" <ci****@theodonnells.plus.com> wrote in message
news:41***********************@ptn-nntp-reader04.plus.net...
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" <no****@hypercon.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
How?
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com>
wrote in message news:OQ**************@TK2MSFTNGP10.phx.gbl...
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" <no****@hypercon.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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
"Wayne" <Me******@community.nospam> wrote in message
news:eP**************@TK2MSFTNGP12.phx.gbl...
>I would suggest threading the fetch.
>
>
> "james" <no****@hypercon.net> wrote in message
> news:uB**************@TK2MSFTNGP14.phx.gbl...
>> 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
>>
>>
>
>



Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dharper | last post by:
I have a table that seems to have a bad index. When I do the following query I get inconsistant and needless to say incorrect results. select count(*) from mytable where mycolumn = 1 If I...
24
by: bazad | last post by:
Hi, I'd like to understand consequences of Application.DoEvents call. Does it create a new thread? Thank you
3
by: dotNETDavid | last post by:
We've broken our app into various assemblies. The WinForm assembly provides the user interface, other assemblies provide various I/O services. I'd like to be able to call...
6
by: Ollie Riches | last post by:
I understand the use of Application.DoEvents() to process all outstanding messages on the message queue in a winforms application if you have long running process on the UI thread. But can anyone...
17
by: Lance | last post by:
I've noticed that calling DoEvents is much slower in an application that has called Application.EnableVisualStyles in Sub Main. Furthermore, the performance seems to worsen each time that DoEvents...
12
by: Jack Russell | last post by:
My unstanding of all VB up to and including vb6 is that an event could not "interrupt" itself. For instance if you had a timer event containing a msgbox then you would only get one message. ...
0
by: Bob | last post by:
I have a sql command with a SearchDate parameter of type date. When I execute its stored procedure from Query Analyzer (to SS2K) with a date out of the valid datetime range, EXEC @SearchDate =...
1
by: codejunkie | last post by:
Hi, I am running a suite of tests of a WIN 32 application. Every test launches the same application, checks if the Application has a Main Window handle and then proceeds. However i am noticing...
12
by: Justin | last post by:
I can attach my code if anyone wants to see it however I'll try to ask my question with some mark up code first. I'm having a problem terminating my process while using DoEvents. For example: ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.