Why do windows go blank?

I am using WinXP SP3 and Excel 2003 SP3 with VBA 6.5.


I have a long-running macro that is CPU-intensive.  However, about every 1 
sec, I log some information and sleep for 20 msec.

After "a while" (it varies), one or more open windows go blank.  That is, 
there is nothing but white inside the window frame.  Moreover, my VBA window 
is no longer the active window -- none is.

When I log to the Immediate Window, that window goes blank very soon, often 
as soon as one page is filled (i.e. the window scrolls).

But this also happens when I log to a file -- and this time, it happened to 
all windows, foreground and background.  (I had walked away from the 
computer for about 45 min.)

The system is still responsive.  When I "break" and end the macro, 
everything is usually restored to normal.  But it is still disconcerting.

Any idea why that happens?  Any idea how I can avoid it?

I suspect this is really a WinXP issue.  Any idea what NG would be monitored 
by responsive people who are knowledgable in this area (the O/S)?

I've tried posting such technical questions to m.p.windowsxp.general in the 
past.  The response are usually not impressive.

I have extensive O/S background, albeit not with MS Windows.  20 msec is 
usually at least two "ticks" (about 33 msec on WinXP).  That is usually 
plenty of time to run other non-CPU-intensive processes, e.g. for window 
updates and timer-based bookkeeping.

Nonetheless, in other circumstances, I have extended the sleep to as much as 
1 sec, to no avail.

0
Joe
12/11/2009 12:01:41 AM
excel.programming 6508 articles. 2 followers. Follow

9 Replies
768 Views

Similar Articles

[PageSpeed] 6

i see this happen many times for many years. i don't like it but it never 
seem to do anything bad so i just say that how excel is sometime whn you use 
screenupdating = false.


"Joe User" <joeu2004> wrote in message 
news:eAGqfUfeKHA.4112@TK2MSFTNGP06.phx.gbl...
|I am using WinXP SP3 and Excel 2003 SP3 with VBA 6.5.
|
|
| I have a long-running macro that is CPU-intensive.  However, about every 1
| sec, I log some information and sleep for 20 msec.
|
| After "a while" (it varies), one or more open windows go blank.  That is,
| there is nothing but white inside the window frame.  Moreover, my VBA 
window
| is no longer the active window -- none is.
|
| When I log to the Immediate Window, that window goes blank very soon, 
often
| as soon as one page is filled (i.e. the window scrolls).
|
| But this also happens when I log to a file -- and this time, it happened 
to
| all windows, foreground and background.  (I had walked away from the
| computer for about 45 min.)
|
| The system is still responsive.  When I "break" and end the macro,
| everything is usually restored to normal.  But it is still disconcerting.
|
| Any idea why that happens?  Any idea how I can avoid it?
|
| I suspect this is really a WinXP issue.  Any idea what NG would be 
monitored
| by responsive people who are knowledgable in this area (the O/S)?
|
| I've tried posting such technical questions to m.p.windowsxp.general in 
the
| past.  The response are usually not impressive.
|
| I have extensive O/S background, albeit not with MS Windows.  20 msec is
| usually at least two "ticks" (about 33 msec on WinXP).  That is usually
| plenty of time to run other non-CPU-intensive processes, e.g. for window
| updates and timer-based bookkeeping.
|
| Nonetheless, in other circumstances, I have extended the sleep to as much 
as
| 1 sec, to no avail.
| 

0
Homey
12/11/2009 11:45:56 AM
"Homey" <none> wrote in message 
news:OP84tdleKHA.5228@TK2MSFTNGP06.phx.gbl...
> how excel is sometime whn you use
> screenupdating = false.

I 'spose I could try that.  But I would not think it would change anything 
because:  (a) the long-running macro is not modifying or even accessing the 
worksheet; and (b) non-Excel windows are also affected adversely.

The other open, but background windows were Outlook Express and Notepad, for 
sure.  I might have also had some IE windows open, accessing some web pages. 
I think the web pages were benign.  But if any of those were Google web 
pages, there could be "a lot" of activity going on, even though they are in 
the backgound.

I did increase my sleep time to 100 msec every 1+ sec.  And I closed all 
windows except the Excel and VBA windows.  The CPU-intensive macro ran for 
45 min without affecting the system adversely.

So maybe the solution is indeed as simple as that.


----- original message -----

"Homey" <none> wrote in message 
news:OP84tdleKHA.5228@TK2MSFTNGP06.phx.gbl...
>i see this happen many times for many years. i don't like it but it never
> seem to do anything bad so i just say that how excel is sometime whn you 
> use
> screenupdating = false.
>
>
> "Joe User" <joeu2004> wrote in message
> news:eAGqfUfeKHA.4112@TK2MSFTNGP06.phx.gbl...
> |I am using WinXP SP3 and Excel 2003 SP3 with VBA 6.5.
> |
> |
> | I have a long-running macro that is CPU-intensive.  However, about every 
> 1
> | sec, I log some information and sleep for 20 msec.
> |
> | After "a while" (it varies), one or more open windows go blank.  That 
> is,
> | there is nothing but white inside the window frame.  Moreover, my VBA
> window
> | is no longer the active window -- none is.
> |
> | When I log to the Immediate Window, that window goes blank very soon,
> often
> | as soon as one page is filled (i.e. the window scrolls).
> |
> | But this also happens when I log to a file -- and this time, it happened
> to
> | all windows, foreground and background.  (I had walked away from the
> | computer for about 45 min.)
> |
> | The system is still responsive.  When I "break" and end the macro,
> | everything is usually restored to normal.  But it is still 
> disconcerting.
> |
> | Any idea why that happens?  Any idea how I can avoid it?
> |
> | I suspect this is really a WinXP issue.  Any idea what NG would be
> monitored
> | by responsive people who are knowledgable in this area (the O/S)?
> |
> | I've tried posting such technical questions to m.p.windowsxp.general in
> the
> | past.  The response are usually not impressive.
> |
> | I have extensive O/S background, albeit not with MS Windows.  20 msec is
> | usually at least two "ticks" (about 33 msec on WinXP).  That is usually
> | plenty of time to run other non-CPU-intensive processes, e.g. for window
> | updates and timer-based bookkeeping.
> |
> | Nonetheless, in other circumstances, I have extended the sleep to as 
> much
> as
> | 1 sec, to no avail.
> |
> 

0
Joe
12/11/2009 5:08:39 PM
I wrote:
> So maybe the solution is indeed as simple as that.

Or not.  Happened again, despite the 100-msec sleep, closing all extraneous 
windows, and minimizing the Excel window.


----- original message -----

"Joe User" <joeu2004> wrote in message 
news:O7SbXSoeKHA.5020@TK2MSFTNGP02.phx.gbl...
> "Homey" <none> wrote in message 
> news:OP84tdleKHA.5228@TK2MSFTNGP06.phx.gbl...
>> how excel is sometime whn you use
>> screenupdating = false.
>
> I 'spose I could try that.  But I would not think it would change anything 
> because:  (a) the long-running macro is not modifying or even accessing 
> the worksheet; and (b) non-Excel windows are also affected adversely.
>
> The other open, but background windows were Outlook Express and Notepad, 
> for sure.  I might have also had some IE windows open, accessing some web 
> pages. I think the web pages were benign.  But if any of those were Google 
> web pages, there could be "a lot" of activity going on, even though they 
> are in the backgound.
>
> I did increase my sleep time to 100 msec every 1+ sec.  And I closed all 
> windows except the Excel and VBA windows.  The CPU-intensive macro ran for 
> 45 min without affecting the system adversely.
>
> So maybe the solution is indeed as simple as that.
>
>
> ----- original message -----
>
> "Homey" <none> wrote in message 
> news:OP84tdleKHA.5228@TK2MSFTNGP06.phx.gbl...
>>i see this happen many times for many years. i don't like it but it never
>> seem to do anything bad so i just say that how excel is sometime whn you 
>> use
>> screenupdating = false.
>>
>>
>> "Joe User" <joeu2004> wrote in message
>> news:eAGqfUfeKHA.4112@TK2MSFTNGP06.phx.gbl...
>> |I am using WinXP SP3 and Excel 2003 SP3 with VBA 6.5.
>> |
>> |
>> | I have a long-running macro that is CPU-intensive.  However, about 
>> every 1
>> | sec, I log some information and sleep for 20 msec.
>> |
>> | After "a while" (it varies), one or more open windows go blank.  That 
>> is,
>> | there is nothing but white inside the window frame.  Moreover, my VBA
>> window
>> | is no longer the active window -- none is.
>> |
>> | When I log to the Immediate Window, that window goes blank very soon,
>> often
>> | as soon as one page is filled (i.e. the window scrolls).
>> |
>> | But this also happens when I log to a file -- and this time, it 
>> happened
>> to
>> | all windows, foreground and background.  (I had walked away from the
>> | computer for about 45 min.)
>> |
>> | The system is still responsive.  When I "break" and end the macro,
>> | everything is usually restored to normal.  But it is still 
>> disconcerting.
>> |
>> | Any idea why that happens?  Any idea how I can avoid it?
>> |
>> | I suspect this is really a WinXP issue.  Any idea what NG would be
>> monitored
>> | by responsive people who are knowledgable in this area (the O/S)?
>> |
>> | I've tried posting such technical questions to m.p.windowsxp.general in
>> the
>> | past.  The response are usually not impressive.
>> |
>> | I have extensive O/S background, albeit not with MS Windows.  20 msec 
>> is
>> | usually at least two "ticks" (about 33 msec on WinXP).  That is usually
>> | plenty of time to run other non-CPU-intensive processes, e.g. for 
>> window
>> | updates and timer-based bookkeeping.
>> |
>> | Nonetheless, in other circumstances, I have extended the sleep to as 
>> much
>> as
>> | 1 sec, to no avail.
>> |
>>
> 

0
Joe
12/11/2009 10:50:05 PM
It happens because VBA is working hard and gives no chance to update the 
interface.
Put some DoEvents in.
Sleep won't help, maybe you can use Application.OnTime instead.

RBS


"Joe User" <joeu2004> wrote in message 
news:eAGqfUfeKHA.4112@TK2MSFTNGP06.phx.gbl...
>I am using WinXP SP3 and Excel 2003 SP3 with VBA 6.5.
>
>
> I have a long-running macro that is CPU-intensive.  However, about every 1 
> sec, I log some information and sleep for 20 msec.
>
> After "a while" (it varies), one or more open windows go blank.  That is, 
> there is nothing but white inside the window frame.  Moreover, my VBA 
> window is no longer the active window -- none is.
>
> When I log to the Immediate Window, that window goes blank very soon, 
> often as soon as one page is filled (i.e. the window scrolls).
>
> But this also happens when I log to a file -- and this time, it happened 
> to all windows, foreground and background.  (I had walked away from the 
> computer for about 45 min.)
>
> The system is still responsive.  When I "break" and end the macro, 
> everything is usually restored to normal.  But it is still disconcerting.
>
> Any idea why that happens?  Any idea how I can avoid it?
>
> I suspect this is really a WinXP issue.  Any idea what NG would be 
> monitored by responsive people who are knowledgable in this area (the 
> O/S)?
>
> I've tried posting such technical questions to m.p.windowsxp.general in 
> the past.  The response are usually not impressive.
>
> I have extensive O/S background, albeit not with MS Windows.  20 msec is 
> usually at least two "ticks" (about 33 msec on WinXP).  That is usually 
> plenty of time to run other non-CPU-intensive processes, e.g. for window 
> updates and timer-based bookkeeping.
>
> Nonetheless, in other circumstances, I have extended the sleep to as much 
> as 1 sec, to no avail.
> 

0
RB
12/11/2009 11:09:06 PM
"RB Smissaert" <bartsmissaert@blueyonder.co.uk> wrote:
> Sleep won't help

Why do think so?

I am referring to the kernel interface.  I have verified that the time
elapsed across the Sleep call is indeed about 100 msec (for Sleep 100), give
or take a few msec (which is understandable).


> It happens because VBA is working hard and gives
> no chance to update the interface.

I don't think so.

For your edification, try running the macro below while Task Manager is open 
to the Performance tab.  It clearly shows a square wave with alternating 
cycles of 100% and near-0% CPU utilization.  QED.

Don't forget to close all windows except Excel, VBA and Task Manager.  I 
also minimize the Excel window.


> maybe you can use Application.OnTime instead.

Why do you think OnTime would have any better behavior than Sleep?

Besides, I indicated the need for msec resolution (originally 30; now 100). 
I believe OnTime has a 1-sec resolution.  In order to get the same "duty 
cycle", the CPU-intensive macro would have to run for 10 sec before blocking 
for 1 sec using OnTime.  I think that would exacerbate the problem, whatever 
it is.


The macro....


Public Declare Sub Sleep Lib "kernel32" (ByVal msec As Long)
Public Declare Function QueryPerformanceFrequency Lib _
    "kernel32" (ByRef freq As Currency) As Boolean
Public Declare Function QueryPerformanceCounter Lib "kernel32" _
   (ByRef cnt As Currency) As Boolean

Sub doit()
Dim freq As Currency, sc As Currency, ec As Currency
Dim dt As Double, i As Integer
QueryPerformanceFrequency freq
'For about 50 sec
For i = 1 To 5
   'CPU-intensive period
   QueryPerformanceCounter sc
   Do
      QueryPerformanceCounter ec
   Loop Until (ec - sc) / freq >= 5
   'Quiescent period
   QueryPerformanceCounter sc
   Sleep 5000
   QueryPerformanceCounter ec
   dt = (ec - sc) / freq
   'Sanity check -- generous tolerance
   If dt < 4.9 Or 5.1 < dt Then Exit For
Next i
'Last sleep duration
MsgBox Format(dt * 1000, "0.000 msec")
End Sub


----- original message -----

"RB Smissaert" <bartsmissaert@blueyonder.co.uk> wrote in message
news:OV3U0breKHA.5808@TK2MSFTNGP06.phx.gbl...
> It happens because VBA is working hard and gives no chance to update the
> interface.
> Put some DoEvents in.
> Sleep won't help, maybe you can use Application.OnTime instead.
>
> RBS
>
>
> "Joe User" <joeu2004> wrote in message
> news:eAGqfUfeKHA.4112@TK2MSFTNGP06.phx.gbl...
>>I am using WinXP SP3 and Excel 2003 SP3 with VBA 6.5.
>>
>>
>> I have a long-running macro that is CPU-intensive.  However, about every
>> 1 sec, I log some information and sleep for 20 msec.
>>
>> After "a while" (it varies), one or more open windows go blank.  That is,
>> there is nothing but white inside the window frame.  Moreover, my VBA
>> window is no longer the active window -- none is.
>>
>> When I log to the Immediate Window, that window goes blank very soon,
>> often as soon as one page is filled (i.e. the window scrolls).
>>
>> But this also happens when I log to a file -- and this time, it happened
>> to all windows, foreground and background.  (I had walked away from the
>> computer for about 45 min.)
>>
>> The system is still responsive.  When I "break" and end the macro,
>> everything is usually restored to normal.  But it is still disconcerting.
>>
>> Any idea why that happens?  Any idea how I can avoid it?
>>
>> I suspect this is really a WinXP issue.  Any idea what NG would be
>> monitored by responsive people who are knowledgable in this area (the
>> O/S)?
>>
>> I've tried posting such technical questions to m.p.windowsxp.general in
>> the past.  The response are usually not impressive.
>>
>> I have extensive O/S background, albeit not with MS Windows.  20 msec is
>> usually at least two "ticks" (about 33 msec on WinXP).  That is usually
>> plenty of time to run other non-CPU-intensive processes, e.g. for window
>> updates and timer-based bookkeeping.
>>
>> Nonetheless, in other circumstances, I have extended the sleep to as much
>> as 1 sec, to no avail.
>>
>

0
Joe
12/12/2009 12:39:41 AM
On Fri, 11 Dec 2009 09:08:39 -0800, "Joe User" <joeu2004> wrote:

>I 'spose I could try that.  But I would not think it would change anything 
>because:  (a) the long-running macro is not modifying or even accessing the 
>worksheet; and (b) non-Excel windows are also affected adversely.


 You *think* it is "not accessing the worksheet".

  I have a 30 MB DVD database that takes a while to do some lookups, and
takes longer on my macro that performs a save/close/re-open, which is
required to convert down to compatibility mode.

  The HD indicator appears as if there is not much other than normal
accesses happening, but if there is a macro running, you can bet it is
looking at the spreadsheet data, even if the 'view' of it is within the
cache.

  When Excel runs a macro, my CPU utilization always jumps to 100% during
the macro running.  It seems to be an error at the base level. The choice
made for how many timeslices to give to a macro or some such.  Either
way, it seems to be too much of a system hog.

  Maybe MS should not have killed that IBM/OS/2 alliance after all. They
could do multi-thread processes way back when...  on a single core.

  You should see how poorly an old DOS based app runs when it was
psuedo-ported to windows.  I have this major brand, expensive label
software that was based on an old DOS app, and they are so greedy that
they have yet to develop a proper windows port of it.  It does NOTHING in
the background, ever.
0
CellShocked
12/12/2009 1:16:26 AM
 Interesting.  Shame that we cannot assign the priority (timeslice) level
of the vb runtime engine.

On Fri, 11 Dec 2009 23:09:06 -0000, "RB Smissaert"
<bartsmissaert@blueyonder.co.uk> wrote:

>It happens because VBA is working hard and gives no chance to update the 
>interface.
>Put some DoEvents in.
>Sleep won't help, maybe you can use Application.OnTime instead.
>
>RBS
>
>
>"Joe User" <joeu2004> wrote in message 
>news:eAGqfUfeKHA.4112@TK2MSFTNGP06.phx.gbl...
>>I am using WinXP SP3 and Excel 2003 SP3 with VBA 6.5.
>>
>>
>> I have a long-running macro that is CPU-intensive.  However, about every 1 
>> sec, I log some information and sleep for 20 msec.
>>
>> After "a while" (it varies), one or more open windows go blank.  That is, 
>> there is nothing but white inside the window frame.  Moreover, my VBA 
>> window is no longer the active window -- none is.
>>
>> When I log to the Immediate Window, that window goes blank very soon, 
>> often as soon as one page is filled (i.e. the window scrolls).
>>
>> But this also happens when I log to a file -- and this time, it happened 
>> to all windows, foreground and background.  (I had walked away from the 
>> computer for about 45 min.)
>>
>> The system is still responsive.  When I "break" and end the macro, 
>> everything is usually restored to normal.  But it is still disconcerting.
>>
>> Any idea why that happens?  Any idea how I can avoid it?
>>
>> I suspect this is really a WinXP issue.  Any idea what NG would be 
>> monitored by responsive people who are knowledgable in this area (the 
>> O/S)?
>>
>> I've tried posting such technical questions to m.p.windowsxp.general in 
>> the past.  The response are usually not impressive.
>>
>> I have extensive O/S background, albeit not with MS Windows.  20 msec is 
>> usually at least two "ticks" (about 33 msec on WinXP).  That is usually 
>> plenty of time to run other non-CPU-intensive processes, e.g. for window 
>> updates and timer-based bookkeeping.
>>
>> Nonetheless, in other circumstances, I have extended the sleep to as much 
>> as 1 sec, to no avail.
>> 
0
CellShocked
12/12/2009 1:19:13 AM
What I mean is that Sleep won't help you to get the interface updated.
How about a little procedure that runs Sleep in a loop with DoEvents 
inter-mixed?
Not sure it will work, but just a suggestion.
Try something like this:

Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub Sleep2(lTotalWait As Long, lInterrupt As Long)

  Dim i As Long
  Dim n As Long

  n = lTotalWait \ lInterrupt

  For i = 1 To n
    Sleep lInterrupt
    DoEvents
  Next i

End Sub

Sub test()
  Sleep2 10000, 1000
End Sub


RBS


"Joe User" <joeu2004> wrote in message 
news:uLfZZOseKHA.5608@TK2MSFTNGP05.phx.gbl...
> "RB Smissaert" <bartsmissaert@blueyonder.co.uk> wrote:
>> Sleep won't help
>
> Why do think so?
>
> I am referring to the kernel interface.  I have verified that the time
> elapsed across the Sleep call is indeed about 100 msec (for Sleep 100), 
> give
> or take a few msec (which is understandable).
>
>
>> It happens because VBA is working hard and gives
>> no chance to update the interface.
>
> I don't think so.
>
> For your edification, try running the macro below while Task Manager is 
> open to the Performance tab.  It clearly shows a square wave with 
> alternating cycles of 100% and near-0% CPU utilization.  QED.
>
> Don't forget to close all windows except Excel, VBA and Task Manager.  I 
> also minimize the Excel window.
>
>
>> maybe you can use Application.OnTime instead.
>
> Why do you think OnTime would have any better behavior than Sleep?
>
> Besides, I indicated the need for msec resolution (originally 30; now 
> 100). I believe OnTime has a 1-sec resolution.  In order to get the same 
> "duty cycle", the CPU-intensive macro would have to run for 10 sec before 
> blocking for 1 sec using OnTime.  I think that would exacerbate the 
> problem, whatever it is.
>
>
> The macro....
>
>
> Public Declare Sub Sleep Lib "kernel32" (ByVal msec As Long)
> Public Declare Function QueryPerformanceFrequency Lib _
>    "kernel32" (ByRef freq As Currency) As Boolean
> Public Declare Function QueryPerformanceCounter Lib "kernel32" _
>   (ByRef cnt As Currency) As Boolean
>
> Sub doit()
> Dim freq As Currency, sc As Currency, ec As Currency
> Dim dt As Double, i As Integer
> QueryPerformanceFrequency freq
> 'For about 50 sec
> For i = 1 To 5
>   'CPU-intensive period
>   QueryPerformanceCounter sc
>   Do
>      QueryPerformanceCounter ec
>   Loop Until (ec - sc) / freq >= 5
>   'Quiescent period
>   QueryPerformanceCounter sc
>   Sleep 5000
>   QueryPerformanceCounter ec
>   dt = (ec - sc) / freq
>   'Sanity check -- generous tolerance
>   If dt < 4.9 Or 5.1 < dt Then Exit For
> Next i
> 'Last sleep duration
> MsgBox Format(dt * 1000, "0.000 msec")
> End Sub
>
>
> ----- original message -----
>
> "RB Smissaert" <bartsmissaert@blueyonder.co.uk> wrote in message
> news:OV3U0breKHA.5808@TK2MSFTNGP06.phx.gbl...
>> It happens because VBA is working hard and gives no chance to update the
>> interface.
>> Put some DoEvents in.
>> Sleep won't help, maybe you can use Application.OnTime instead.
>>
>> RBS
>>
>>
>> "Joe User" <joeu2004> wrote in message
>> news:eAGqfUfeKHA.4112@TK2MSFTNGP06.phx.gbl...
>>>I am using WinXP SP3 and Excel 2003 SP3 with VBA 6.5.
>>>
>>>
>>> I have a long-running macro that is CPU-intensive.  However, about every
>>> 1 sec, I log some information and sleep for 20 msec.
>>>
>>> After "a while" (it varies), one or more open windows go blank.  That 
>>> is,
>>> there is nothing but white inside the window frame.  Moreover, my VBA
>>> window is no longer the active window -- none is.
>>>
>>> When I log to the Immediate Window, that window goes blank very soon,
>>> often as soon as one page is filled (i.e. the window scrolls).
>>>
>>> But this also happens when I log to a file -- and this time, it happened
>>> to all windows, foreground and background.  (I had walked away from the
>>> computer for about 45 min.)
>>>
>>> The system is still responsive.  When I "break" and end the macro,
>>> everything is usually restored to normal.  But it is still 
>>> disconcerting.
>>>
>>> Any idea why that happens?  Any idea how I can avoid it?
>>>
>>> I suspect this is really a WinXP issue.  Any idea what NG would be
>>> monitored by responsive people who are knowledgable in this area (the
>>> O/S)?
>>>
>>> I've tried posting such technical questions to m.p.windowsxp.general in
>>> the past.  The response are usually not impressive.
>>>
>>> I have extensive O/S background, albeit not with MS Windows.  20 msec is
>>> usually at least two "ticks" (about 33 msec on WinXP).  That is usually
>>> plenty of time to run other non-CPU-intensive processes, e.g. for window
>>> updates and timer-based bookkeeping.
>>>
>>> Nonetheless, in other circumstances, I have extended the sleep to as 
>>> much
>>> as 1 sec, to no avail.
>>>
>>
> 

0
RB
12/12/2009 7:35:06 AM
"RB Smissaert" <bartsmissaert@blueyonder.co.uk> wrote:
>    Sleep lInterrupt
>    DoEvents

Thanks for the pointer.  I was not aware of DoEvents and the potential need 
for it.

Having just read the help page, yes, calling DoEvents before or after or 
perhaps instead of Sleep sounds like a good idea.


----- original message -----

"RB Smissaert" <bartsmissaert@blueyonder.co.uk> wrote in message 
news:ed%23Ml2veKHA.2780@TK2MSFTNGP05.phx.gbl...
> What I mean is that Sleep won't help you to get the interface updated.
> How about a little procedure that runs Sleep in a loop with DoEvents 
> inter-mixed?
> Not sure it will work, but just a suggestion.
> Try something like this:
>
> Option Explicit
> Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
>
> Sub Sleep2(lTotalWait As Long, lInterrupt As Long)
>
>  Dim i As Long
>  Dim n As Long
>
>  n = lTotalWait \ lInterrupt
>
>  For i = 1 To n
>    Sleep lInterrupt
>    DoEvents
>  Next i
>
> End Sub
>
> Sub test()
>  Sleep2 10000, 1000
> End Sub
>
>
> RBS
>
>
> "Joe User" <joeu2004> wrote in message 
> news:uLfZZOseKHA.5608@TK2MSFTNGP05.phx.gbl...
>> "RB Smissaert" <bartsmissaert@blueyonder.co.uk> wrote:
>>> Sleep won't help
>>
>> Why do think so?
>>
>> I am referring to the kernel interface.  I have verified that the time
>> elapsed across the Sleep call is indeed about 100 msec (for Sleep 100), 
>> give
>> or take a few msec (which is understandable).
>>
>>
>>> It happens because VBA is working hard and gives
>>> no chance to update the interface.
>>
>> I don't think so.
>>
>> For your edification, try running the macro below while Task Manager is 
>> open to the Performance tab.  It clearly shows a square wave with 
>> alternating cycles of 100% and near-0% CPU utilization.  QED.
>>
>> Don't forget to close all windows except Excel, VBA and Task Manager.  I 
>> also minimize the Excel window.
>>
>>
>>> maybe you can use Application.OnTime instead.
>>
>> Why do you think OnTime would have any better behavior than Sleep?
>>
>> Besides, I indicated the need for msec resolution (originally 30; now 
>> 100). I believe OnTime has a 1-sec resolution.  In order to get the same 
>> "duty cycle", the CPU-intensive macro would have to run for 10 sec before 
>> blocking for 1 sec using OnTime.  I think that would exacerbate the 
>> problem, whatever it is.
>>
>>
>> The macro....
>>
>>
>> Public Declare Sub Sleep Lib "kernel32" (ByVal msec As Long)
>> Public Declare Function QueryPerformanceFrequency Lib _
>>    "kernel32" (ByRef freq As Currency) As Boolean
>> Public Declare Function QueryPerformanceCounter Lib "kernel32" _
>>   (ByRef cnt As Currency) As Boolean
>>
>> Sub doit()
>> Dim freq As Currency, sc As Currency, ec As Currency
>> Dim dt As Double, i As Integer
>> QueryPerformanceFrequency freq
>> 'For about 50 sec
>> For i = 1 To 5
>>   'CPU-intensive period
>>   QueryPerformanceCounter sc
>>   Do
>>      QueryPerformanceCounter ec
>>   Loop Until (ec - sc) / freq >= 5
>>   'Quiescent period
>>   QueryPerformanceCounter sc
>>   Sleep 5000
>>   QueryPerformanceCounter ec
>>   dt = (ec - sc) / freq
>>   'Sanity check -- generous tolerance
>>   If dt < 4.9 Or 5.1 < dt Then Exit For
>> Next i
>> 'Last sleep duration
>> MsgBox Format(dt * 1000, "0.000 msec")
>> End Sub
>>
>>
>> ----- original message -----
>>
>> "RB Smissaert" <bartsmissaert@blueyonder.co.uk> wrote in message
>> news:OV3U0breKHA.5808@TK2MSFTNGP06.phx.gbl...
>>> It happens because VBA is working hard and gives no chance to update the
>>> interface.
>>> Put some DoEvents in.
>>> Sleep won't help, maybe you can use Application.OnTime instead.
>>>
>>> RBS
>>>
>>>
>>> "Joe User" <joeu2004> wrote in message
>>> news:eAGqfUfeKHA.4112@TK2MSFTNGP06.phx.gbl...
>>>>I am using WinXP SP3 and Excel 2003 SP3 with VBA 6.5.
>>>>
>>>>
>>>> I have a long-running macro that is CPU-intensive.  However, about 
>>>> every
>>>> 1 sec, I log some information and sleep for 20 msec.
>>>>
>>>> After "a while" (it varies), one or more open windows go blank.  That 
>>>> is,
>>>> there is nothing but white inside the window frame.  Moreover, my VBA
>>>> window is no longer the active window -- none is.
>>>>
>>>> When I log to the Immediate Window, that window goes blank very soon,
>>>> often as soon as one page is filled (i.e. the window scrolls).
>>>>
>>>> But this also happens when I log to a file -- and this time, it 
>>>> happened
>>>> to all windows, foreground and background.  (I had walked away from the
>>>> computer for about 45 min.)
>>>>
>>>> The system is still responsive.  When I "break" and end the macro,
>>>> everything is usually restored to normal.  But it is still 
>>>> disconcerting.
>>>>
>>>> Any idea why that happens?  Any idea how I can avoid it?
>>>>
>>>> I suspect this is really a WinXP issue.  Any idea what NG would be
>>>> monitored by responsive people who are knowledgable in this area (the
>>>> O/S)?
>>>>
>>>> I've tried posting such technical questions to m.p.windowsxp.general in
>>>> the past.  The response are usually not impressive.
>>>>
>>>> I have extensive O/S background, albeit not with MS Windows.  20 msec 
>>>> is
>>>> usually at least two "ticks" (about 33 msec on WinXP).  That is usually
>>>> plenty of time to run other non-CPU-intensive processes, e.g. for 
>>>> window
>>>> updates and timer-based bookkeeping.
>>>>
>>>> Nonetheless, in other circumstances, I have extended the sleep to as 
>>>> much
>>>> as 1 sec, to no avail.
>>>>
>>>
>>
> 

0
Joe
12/12/2009 8:28:31 AM
Reply:

Similar Artilces:

SmartList Builder Go-To to Sales Transaction Inquiry Zoom
Hello: I have used the TK doc on how to build a Go-To that will bring up the Sales Transaction Entry window, upon double-clciking on a sales order record in a sales order SmartList icreated by SmartList Builder. It's pretty easy to follow. But, the same "concept" apparently does not apply when you create a SmartList containing history sales transaction tables. Could someone please post instructions on how to configure a Go-To to pull up the Sales Transaction Inquiry Zoom window upon double-clicking on a sales invoice record in a sales history SmartList created in Smart...

Problem with Chart drawing blank cells as zero
Hi I am currently trying to create an excel line chart showing cumulative baseline vs Cumulative Actual vs forecast actual lines (the forecast line is a continuation of the Actual to date line) which I have done - but am trying to automate it so it is 'more user friendly' and can be created at the touch of a macro. The problem I am having is that one of the formulae i am using looks up a date in the timescale and if it is in the future I want it to leave the cell bank (using the "" option" - problem is the chart then decides this is not a blank cell it is a zero ...

windows mail
This laptop was given to me, windows mail was set up by the previous owner (my 82 yr old grandmother) how do I change it to my email address? I tried, not sure what I did but it keeps saying this <<please also note I do not use yahoo and want it to be gmail>> (and I have done the 32 bit upgrade for messages stuck in outbox) The host 'verizon yahoo' could not be found. Please verify that you have entered the server name correctly. Subject 'Emailing: Tim 70's', Account: 'verizon yahoo', Server: 'verizon yahoo', Protocol: SMTP, Port: ...

Synchronize Office Information with Pocket PC (Windows Mobile 2003
I've downloaded Office 2007 (Beta2) and Activesync 4.1. Why can't I do the following: 1. Sync or select Contacts, Calendar, Notes in Activesync 4.1 2. Access the Internet from my PPC when partnership was successful. 3. Import/Export mail accounts from Office Outlook(message:"not implemented". ...

How can I open Internet Explorer8 window maximized?
I am using Window XP. Within an IE8 page, if I click a link, it will open a new window with small size. Is there a way to open it in full size? I try ctrl, or shift key to max it and exit it, but they did not work. Thank a lot. Chris Any window you want to resize permanently must be the /last/ window closed. Grab the corners of the window and drag it to full screen size. Do not use Maximize. Close all other windows first via the Taskbar and this one last. Windows will remember the *last* screen size used the next time you open the program. -- Bru...

Blank e-mails #3
we have been receiving e-mails that have no date, no subject and no content. Our ISP says that this is an Outlook Express problem and to search support. We can't find anything? Dick <anonymous@discussions.microsoft.com> wrote: > we have been receiving e-mails that have no date, no > subject and no content. Our ISP says that this is an > Outlook Express problem and to search support. > We can't find anything? Ask in an Outlook Express newsgroup. Try REGSVR32 INETCOMM.DLL at a command line prompt. -- Brian Tillman ...

Windows Terminal Server 2008 / non-clients need to access internet
I have a terminal server environment. I have access points all over the school. I would like visitors to be able to access the internet but in order to get on you have to open a session. How do I get it shared to non-client pcs? -- rubantin ------------------------------------------------------------------------ rubantin's Profile: http://forums.techarena.in/members/190718.htm View this thread: http://forums.techarena.in/windows-server-help/1311934.htm http://forums.techarena.in Hello rubantin, "How do I get it shared to non-client pcs?" Do you mean with ...

What does Excel do when you go over the limit for total data point
The maximum number of total data points in a plot is 256,000. However, I have setup plots with > 1.5 million data points. Excel does not complain about this, but I'm guessing it is still only showing 256,000 points. The thing is, I can't figure out which 256,000 it is showing. I don't think it's just the first 256,000 because the data is sorted and it would look abruptly cutoff after the 256,000th point. I'm using a scatterplot if that helps. The plot looks correct, with gradually decreasing density towards the outer edges of the plot. But if it's only ...

Having trouble sending email from windows mail
This is the error message that I receive when I try and send and email. What does it mean? The message could not be sent. The authentication setting might not be correct for your outgoing e-mail [SMTP] server. For help solving this problem, go to Help, search for "Troubleshoot Windows Mail", and read the "I'm having problems sending e-mail" section. If you need help determining the proper server settings, please contact your e-mail service provider. Where is the second part of the error message? That is the most important. -- Bruce Hage...

Going From MFC to .NET
I hope someone can help me on this! here is what's happening: Big project created on MFC C++ with extensive GUI etc... I tryed to open this project using .NET and everything is fine from GUI to project settings etc... Now the problem is that when I try to compile a debug or release vr. the project gives the following error after successfully compiling all of the other codes: //**THIS IS JUST PART OF THE OUTPUT**// Linking... C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\lib\msimg32.lib : warning LNK4003: invalid library format; library ignored C:\Program Files\Micros...

Priting from a splitter window
I am attempting access the onPrint function of a splitter window. I have six splitter windows, of which the top left window is a formview. The print menu item messages the formview, which does not print anything. What I would really like to do is print the contents of the "second" splitter window. How can I direct the print message to the correct splitter window? I am using the SplitterWndEx class as described in http://www.codeguru.com/mfc/comments/7113.shtml Any help would be greatly appreciated. Thank You, Pat You never print the splitter window itself, but the view it sp...

Vbscript to create sites on a windows 2008 DC
Hello, I am trying to use this script provided by MS to create a site on my windows 2008 DC: However, it does not work. I get an error saying:There is a naming violation for line: Set objSite = objSitesContainer.Create("site", strSiteRDN) objSite.SetInfo Here is the script. Is it not intended to work in windows 2008? Thanks! strSiteRDN = "cn=Ga-Atl-Sales" strSiteLinkRDN = "cn=DEFAULTIPSITELINK" strSiteLinkType = "IP" Const ADS_PROPERTY_APPEND = 3 Set objRootDSE = GetObject("LDAP://RootDSE...

mini frame windows in MDI apps
Does anyone know how I can have my MDI child frame windows use the narrow title bars similar to those used in CMiniFrameWnd? Thanks ...

How to disable Window File protection system
Hello, I need to implement a class that disbales Windows File Protection (WFP) untill next reboot and that shouldn't require Rebooting the system. Please help me out if anyone has idea about it, Regards Amit ...

Would like to have local graphic files displayed by Windows Picture Viewer instead of Internet Explorer
My spreadsheet contains a bunch of the so-called hyperlinks which, when clicked, start an external program that takes care of the actual displaying of the image file. Is there any way to select the external program (file viewer)? All the graphics files (PNG format) reside in my hard disk, not on the Internet. This case is handled very nicely by Open Office, with the images being handled by the Windows Picture and Fax Viewer which loads lightning fast. Excel, on the other hand, prefers to use Internet Explorer, which is a drag. Can I tell Excel NOT to execute IE for some hyperlinks? -Ramo...

Windows 2008 compatability
We have a customer who is looking to upgrade their server to Windows 2008 from Windows 2003. They are currently running GP 8.0. Is Windows 2008 compatable with that version of GP? The question is more, is GP 8 compatible with Windows 2008 and the answer is no. However, if you like the new brave world we live in, you can run GP 8.0 in Windows 2003 R2 compatibility mode while on Windows 2008. Best regards, -- MG.- Mariano Gomez, MIS, MCP, PMP Maximum Global Business, LLC http://www.maximumglobalbusiness.com The Dynamics GP Blogster at http://dynamicsgpblogster.blogspot.com "Susa...

Add fields of Scroll window in VBA ?
Hi, I am able to add other fields in form but I am unable to add fields of scrolling window in VBA. Thanks in advance -- Aditya While I'm happy you have things solved, I don't believe what you have below is the correct solution. You should be able to add any fields of any scrolling window to your project. I'm darn sure that is the case because I've used VBA to pull values from lookup windows before and those are of course browse only. My only note for scrolling windows is you have to make sure the window is "filled" before you try to add it to vba. ...

Outlook 98 and Windows XP
OK, I have been all around the Microsoft supports pages, many, many chat areas, and about a half dozen other sites that I thought could help, but I still have not found an answer to my confusing questions. Everytime Outlook 98 is started on my system, which runs Windows XP, in three minutes (to the second) I get an error that reads "outlook.exe has encountered a problem and must close...blah blah blah" I can move this error window out of the way and continue to use Outlook except it slows everything down including the other programs running on my system. As soon as I ei...

Microsoft Update under Windows 7 shows [Error number: 0x8DDD0004]
I got a new HP notebook Elitebook 8540p with Windows 7 Professional preinstalled. When trying to run Windows Update everything works ok. When I try to run Microsoft Update (http://update.microsoft.com) in order to update all the other Microsoft programs like Office etc I get [Error number: 0x8DDD0004]. Strange thing is that the first add-on ('Windows Update' from 'Microsoft Windows Component Publisher') shows as unknown program from unknown publisher... I would expect it is signed as coming from Microsoft??? As per instruction from Microsoft I followed A...

Blank lines on line input
Hi I'm using a recordset to read a text file and input the data into an access 2000 table. My problem is I want the line input to treat a blank line as eof, there is information after the blank line but I don't need to import it. This is my code Function ap1() Dim Filepath As String Dim Currentfile As String Dim rs As DAO.Recordset ' Database Dim fh As Integer ' File handle Dim lc As Long ' Line counter Dim ln As String ' Actual line Dim sp As Long ' Position of first space Dim thefile As S...

Enterprise version of Windows 2003 necessary for Exchange?
Hello, If I want to install E2k3 Enterprise edition, do I need Windows 2003 Enterprise edition anywhere, e.g., on separate DCs or GCs? Do I even need it on the Exchange server itself? Just double-checking... Thanks, - Alan. On 26 Oct 2006 05:57:41 -0700, "Alan" <bruguy@gmail.com> wrote: >Hello, > >If I want to install E2k3 Enterprise edition, do I need Windows 2003 >Enterprise edition anywhere, e.g., on separate DCs or GCs? Do I even >need it on the Exchange server itself? > >Just double-checking... > >Thanks, > >- Alan. Nope. Standard ...

font problem in Chinese/Japanese Windows
Hi, We are a commercial software firm, and have been using MFC platform for years. Since last year, we have been bothered by the application package dialog box got stray/oversize/chopped text display in Chinese and Japanese Windows (mainly XP). Our application runs fine on WinXP/Vista in English Windows systems. Is there any quick way to fix this problem (such as using font substitution ?) Thanks Ted You could try to use a different font better suited to those characters using this technique: http://msdn2.microsoft.com/en-us/library/ms903933.aspx Tom "Ted" <NOSPAM...

Windows SBS 2008 VPN Issue
Hi Group I have a Issue in SBS 2008. I have installed SBS 2008 and server is in factory .But I can not make multiple connections from branch office I can create only one VPN connection So please help me with this problem. Regards Atul sood Hi Atul: In general, VPN connection with the SBS as the endpoint are not very usful and can restrict the bandwidth by fragmenting the usable upload speed which is generally not all that great to start. The best suggestions I can give you are to either use hardware appliances at each end to create the VPN, and, or to use RWW to land...

on last enter start new blank form
is there a way to have a new blank form start after entering last input of information? Thanks in advance for the help! If you set the form's property to add new records, and add a <Save> command button, you should get "a new blank form". If you're asking how to have it happen without the <Save> button, how will Access "know" when you're finished entering data? Regards Jeff Boyce Microsoft Access MVP -- Disclaimer: This author may have received products and services mentioned in this post. Mention and/or description of a produ...

Moving Office 2007 settings from an XP machine to a Windows 7 ma
Recently built a new machine, and want to move settings (including customizations and outlook rules, mailboxes and accounts) to the new machine. As noted in the title, the old machine is an XP Pro box, the new machine is running Windows 7. I’d rather not move macros and add-ins all at once (something is causing a problem and I’d like to install one at a time), but the Outlook set up and little tweaks (e.g., customization changes, style sets) will be a PITA to redo manually. I found a dizzying array of answers via Google, but none seemed to apply. Wasn’t there a built-in too...