By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,304 Members | 1,739 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,304 IT Pros & Developers. It's quick & easy.

What happens in procedure 1 the very instant sub procedure 2 is called?

P: n/a
MLH
Consider the following class module...
Option Compare Database
Option Explicit

Private Sub Command0_Click()
MsgBox "One"
Call MySub
MsgBox "Three"
End Sub

-------------------------------------------------------------

Private Sub MySub()
MsgBox ("Two")
End Sub

When the Call MySub line is executed in Sub Command0_Click,
are remaining lines to be processed in the first Sub completely
suspended until processing in Sub MySub is completed. Is there
EVER any possibility of any lines in the first sub being processed
until Sub MySub is completely finished or terminated earlier by
error?

To make the question perfectly clear - is there any possibility that
lines from both subs could EVER be processing in 2 concurrent
threads?
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
MLH <CR**@NorthState.net> wrote in
news:al********************************@4ax.com:
To make the question perfectly clear - is there any
possibility that lines from both subs could EVER be processing
in 2 concurrent threads?


That won't happen, as long as the code is in the same module, and
not triggered from an event

Put a second command button on a form, and you can get interleaving
from each of the two subs.

If you have code in a form that opens a second form, the code in
each form may run concurrently with the code from the other form.

--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #2

P: n/a
MLH
Thx, Bob.
xxxxxxxxxxxxxxxxxxxxx

That won't happen, as long as the code is in the same module, and
not triggered from an event

Put a second command button on a form, and you can get interleaving
from each of the two subs.

If you have code in a form that opens a second form, the code in
each form may run concurrently with the code from the other form.


Nov 13 '05 #3

P: n/a
MLH <CR**@NorthState.net> wrote in
news:al********************************@4ax.com:
Consider the following class module...
Option Compare Database
Option Explicit

Private Sub Command0_Click()
MsgBox "One"
Call MySub
MsgBox "Three"
End Sub

-------------------------------------------------------------

Private Sub MySub()
MsgBox ("Two")
End Sub

When the Call MySub line is executed in Sub Command0_Click,
are remaining lines to be processed in the first Sub completely
suspended until processing in Sub MySub is completed. Is there
EVER any possibility of any lines in the first sub being processed until Sub MySub is completely finished or terminated earlier by
error?

To make the question perfectly clear - is there any possibility
that lines from both subs could EVER be processing in 2 concurrent threads?


Well, that depends entirely on what you're calling code does.

If it's asynchronous, it will return control back to the original
context and continue executing the next line. If it's not, it
won't.

There's no way to say for sure without knowing exactly what code
you're calling.

If, for instance, your called MySub() makes a call to Shell() it
will return control back to the calling sub before Shell() has
finished, since Shell() always executes asynchronously (it you want
to avoid that with Shell(), look up ShellAndWait() on the Access
web).

Another example: DoCmd.OpenForm executes asynchronously when you
don't use the acDialog argument.

THe answer to your question is entirely dependent on what your code
does.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #4

P: n/a
MLH
Well then, there are instances in which it can go either way.
Alright. That will be handy to know if there are any dependencies
I'm counting on in code that might NOT be suspended. Would
be tough for me to have known this if I were to be caught in
some kind of race condition that was prducing an error as a
result.

Thx, David.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxx

Well, that depends entirely on what you're calling code does.

If it's asynchronous, it will return control back to the original
context and continue executing the next line. If it's not, it
won't.

There's no way to say for sure without knowing exactly what code
you're calling.

If, for instance, your called MySub() makes a call to Shell() it
will return control back to the calling sub before Shell() has
finished, since Shell() always executes asynchronously (it you want
to avoid that with Shell(), look up ShellAndWait() on the Access
web).

Another example: DoCmd.OpenForm executes asynchronously when you
don't use the acDialog argument.

THe answer to your question is entirely dependent on what your code
does.


Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.