Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Possible to terminate a sub that loads another sub?

Reply
Thread Tools

Possible to terminate a sub that loads another sub?

 
 
Kathy Burke
Guest
Posts: n/a
 
      11-21-2003
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!
 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      11-22-2003
"Kathy Burke" <> wrote in message
news:...
> 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


 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      11-22-2003
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" <> wrote in message
news:...
> 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!



 
Reply With Quote
 
Kathy Burke
Guest
Posts: n/a
 
      11-24-2003
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!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Death To Sub-Sub-Sub-Directories! Lawrence D'Oliveiro Java 92 05-20-2011 06:50 AM
Recognising Sub-Items and sub-sub items using xslt Ben XML 2 09-19-2007 09:35 AM
Is it possible to list sessions and terminate one? Brian Cryer ASP .Net 1 09-26-2006 03:54 PM
How can we access a text box in a "sub" that has been created in another "sub" dynamically loga123 ASP .Net 2 05-20-2006 08:47 AM
Slow page loads, possible security issue? Scott F. Brown ASP .Net 1 10-22-2003 01:32 PM



Advertisments