[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

is vbs event handling actually multi-threading?

Posted on 2005-05-07
5
Medium Priority
?
329 Views
Last Modified: 2010-05-02
if i've got an application that is just a loop with a counter in it - adn that loop updates a label on a form with that counter but every 100 iterations it raises an event for which the event handler contains quite complex code - how does vb handle this?

i.e. - will my loop continue to run while the event is handled?  or can vb only do one or the other?

i.e. - i need my loop to keep going (obviously in my applciation its not just incrementing a counter - its doing database work) - but i also need the events that get raised to be handled at the same time.  Can i do that?
0
Comment
Question by:kenshaw
5 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 13950686
Instead of using a loop use a timer.  In the "complex operation" code that gets called every 100 iterations, be sure place DoEvents in any loops to allow the timer code to fire and be processed.
0
 
LVL 4

Author Comment

by:kenshaw
ID: 13950724
well... i sort of wrote it like that for a reason.  i'm maintaining code and i can't get rid of the loop.  the loop code has about 200 lines of code in it - and it needs to be a loop b/c its processing a recordset.

does anyone know the answer to the question?
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 13952432
then as idle_mind said, use doevents
0
 
LVL 4

Author Comment

by:kenshaw
ID: 14055718
I don't think anyone really answered this question.  I think the moderator should delete it.
0
 
LVL 1

Accepted Solution

by:
mazhar earned 2000 total points
ID: 14184764
vb event handling is NOT multi-threading nor asynchronous.  When the event gets fired, VB will rush off to execute code for the event, not continuing to do whatever you do in your loop.  Also, once the code for the event completes execution, vb will not then "come back" to executing the code in your loop.  Of course, this is all based on the assumption that you have a doevents inside your loop, so that the event code will get started to begin with.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month19 days, 14 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question