472,362 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Possible to terminate a sub that loads another sub?

Hi, I'm tired, so this question may be silly. I have a fairly long sub
procedure. Based on one condition, I load another sub with the
following:

If Session("GRN") = "complete" Then
txtScan.Text = Session("SN")
txtScan_TextChanged(sender, e)
Session("GRN") = ""
Exit Sub
End If

The txtScan_TextChanged sub loads another user page, which may be open
for a while (keeping the parent sub open as well). Then when the user
"ends" the child sub, the parent sub picks at line Session("GRN") = ""
and Exits the parent.

Just wondering, if this is the best/only way to do this? It disturbs me
a bit to see a page "loading" in the browser for such a period of time.
Make any sense at all?

Thanks,
Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
3 2368
"Kathy Burke" <ka**********@attbi.com> wrote in message
news:OY**************@TK2MSFTNGP09.phx.gbl...
Hi, I'm tired, so this question may be silly. I have a fairly long sub
procedure. Based on one condition, I load another sub with the
following:

If Session("GRN") = "complete" Then
txtScan.Text = Session("SN")
txtScan_TextChanged(sender, e)
Session("GRN") = ""
Exit Sub
End If

Kathy,

Go get some sleep. Sub procedures don't "load" or keep their parent subs
open. You're very confused about something.
--
John Saunders
John.Saunders at SurfControl.com
Nov 18 '05 #2
I think I understand. Let me regurgitate this back to you in my own words
first, to make sure. You're concerned about how long it takes for your Page
to process because a Sub is being called (I believe this is what you mean by
"load") by another Sub, and the second Sub takes a long time to run, which
causes the first Sub to take a long time to run, as control is returned to
the first Sub only after the second Sub has finished. Correct? Again, if I
understand correctly, you're asking if there is a way to terminate the first
Sub after calling the second one. Right?

If so, the answer is going to be a little tricky to understand, as we'll
have to discuss threading. When a class loads, it loads into a thread of
execution. The thread follows a course of execution which can meander from
one Method to another until it is finished executing. It does precisely one
thing at a time. That is why the first Sub doesn't exit until the second Sub
is finished. The thread exits the first Sub at the point at which it calls
the second, runs through the second Sub (and any methods which the second
Sub calls), and returns to the point at which it left the first when it is
finished, and completes its run through the first.

..Net is multi-threaded, which means that you can run multiple threads of
execution at one time. Threading is complex and tricky, because when you
spawn multiple threads in a class, they all exist more or less independently
of one another, and execute asynchronously (meaning that their execution is
not coordinated or synchronized). In addition, they all belong to the same
context, and work with the same properties and methods in the class and
context from which they were spawned. There are ways of synchronizing
threads as well, when it is necessary to do so. This is accomplished by
establish "waiting Points" for threads, at which they must wait until
another thread "catches up" to continue executing.

In any case, if, for example, the second Sub is going to do something which
the first Sub and any subsequent "stops" along its thread of execution will
not be depending upon, you can spawn the second Sub in a separate thread.
When you do this, the Method call to the second Sub is executed, and the
first Sub continues on regardless of the state of execution of the second
Sub thread.

The following MSDN article should be helpful:

http://msdn.microsoft.com/library/de...ingthreads.asp

--
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Kathy Burke" <ka**********@attbi.com> wrote in message
news:OY**************@TK2MSFTNGP09.phx.gbl...
Hi, I'm tired, so this question may be silly. I have a fairly long sub
procedure. Based on one condition, I load another sub with the
following:

If Session("GRN") = "complete" Then
txtScan.Text = Session("SN")
txtScan_TextChanged(sender, e)
Session("GRN") = ""
Exit Sub
End If

The txtScan_TextChanged sub loads another user page, which may be open
for a while (keeping the parent sub open as well). Then when the user
"ends" the child sub, the parent sub picks at line Session("GRN") = ""
and Exits the parent.

Just wondering, if this is the best/only way to do this? It disturbs me
a bit to see a page "loading" in the browser for such a period of time.
Make any sense at all?

Thanks,
Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #3
Kevin, excellent interpretation...that is exactly what I meant!

Thanks for the explanation and info...I'll go investigate the link you
gave me.

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4

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

Similar topics

2
by: KathyB | last post by:
One more question...please. I have an xml doc like this: <assembly> <station name="station1"> <wi id="1" name="doc231"> <boards> <board sn="1111" start="07/15/03" end="07/16/03" /> <board...
4
by: Dr. J | last post by:
How to terminate a blocked thread? In my form's "load" I launch a TCP listening thread that stays in an infinite loop waiting for incoming TCP packets. In this form's "closing" I try to...
15
by: _BNC | last post by:
Recently I had posted a query about intermittent problems with a C++/Interop scheme (unmanaged C DLL wrapped in unmanaged C++, wrapped in managed C++, all accessed by C#). The system works fine...
3
by: Arran Pearce | last post by:
Not sure if what i want to do will work. If i start a new thread in the Application_Start event is there a risk that that thread will be forced to stop? If no user uses my site for a while...
4
by: TJ | last post by:
Hi, There is one aspx web page that contains usercontrol. In aspx page and usercontrol , there is each submit button... Here is what I want... I want to process something depending on each...
2
by: Ron Sellers | last post by:
I have built a VB.Net app that runs fine when the Windows desktop resolution is set to normal (100%). When the Display Properties>Settings>Advanced>Display>Font Size is set to "Large Fonts"...
3
by: Keith Grefski | last post by:
I cant seem to figure out how to terminate a process in vb.net i can do it using vbscript and wmi but terminate doesnt seem to exist in the available classes for wmi under vb.net
5
by: Chris Ochs | last post by:
It doesn't currently seem possible to switch between different users using SET SESSION AUTHORIZATION. If I log in as the superuser and switch to another user that works, but if I then switch to a...
1
by: Justin | last post by:
We had a load that failed. Now we have a pending load. When executing load terminate, we receive the following error: db2 load terminate SQL0104N An unexpected token "terminate" was found...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
0
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...

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.