473,387 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 2443
"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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.