Question about DoEvents

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hello,
I have a program running that calls to an ActiveX.exe. The activex exe has
a timer event in it that kicks off a process that reads from a queue and
does some processing, it also has a method that adds an item to the queue
from a client app. It looks like this:

'Client
sub additem(item as object)
mAXexe.addToQueue item
end sub

Server

public sub addToQueue(item as object)
'code to add item to queue.
doevents
end sub

private sub timer1_timer()
'loop through queue
do until endofqueue
'processqueueitem
doevents
loop
end sub


Now, this has been running for some time now without a problem, but the
other day, the client app was hung with the "Switch to/retry" box. The only
external call from the client is made to add an item to the server's queue.
I wonder if perhaps the doevents in the addToQueue sub in the server is
firing, and control is going to the timer event (If the timer event fires at
the exact time an item is added) and then control will not be returned to
the addToQueue event until the processing is done (which can take several
minutes or more.)

I have removed the doEvents from the addToQueue method, and the problem
hasn't re-occurred, but it only happened the one time anyway, so I don't
know if I've fixed the problem or not. Is my diagnosis accurate as to what
could be happening, or do you think I should keep digging around in there?

Lance


.



Relevant Pages

  • Re: Code executing too fast -- causes errors
    ... is also a queue of messages waiting to be processed. ... As you say, sleep suspends execution for a given duration, then resumes ... The key difference between the two approaches is that DoEvents will permit ... Private Sub CommandButton1_Click ...
    (microsoft.public.word.vba.beginners)
  • Re: Question about DoEvents
    ... DoEvents in your queue processing code, but I suspect you have it ... Does DoEvents work with ActiveX calls though? ... The problem as I saw it was that processing one item from the queue could ... and control is going to the timer event (If the timer event fires at ...
    (microsoft.public.vb.general.discussion)
  • Re: Question about DoEvents
    ... If the queue is processing, it will accept additional queue items, and will ... doevents in the addItem method, it made me think that the doevents fired ... just as the timer event was firing to check for additional items (which it ... I wonder if perhaps the doevents in the addToQueue sub in the server is ...
    (microsoft.public.vb.general.discussion)
  • Re: Code executing too fast -- causes errors
    ... Sleep, as far as I can see, does not send the thread to sleep, but rather ... is it somehow queue jumping over the threads waiting in ... The key difference between the two approaches is that DoEvents will ... Private Sub CommandButton1_Click ...
    (microsoft.public.word.vba.beginners)
  • Re: Remove method and releasing memory question
    ... simplify your queue and stack. ... Public Sub Add ... Public Function RemoveAs Variant ...
    (microsoft.public.vb.general.discussion)