Possible to terminate a sub that loads another sub?

Discussion in 'ASP .Net' started by Kathy Burke, Nov 21, 2003.

  1. Kathy Burke

    Kathy Burke Guest

    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!
    Kathy Burke, Nov 21, 2003
    #1
    1. Advertising

  2. "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
    John Saunders, Nov 22, 2003
    #2
    1. Advertising

  3. 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/d...en-us/dv_vstechart/html/vbtchusingthreads.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!
    Kevin Spencer, Nov 22, 2003
    #3
  4. Kathy Burke

    Kathy Burke Guest

    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!
    Kathy Burke, Nov 24, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott F. Brown

    Slow page loads, possible security issue?

    Scott F. Brown, Oct 21, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    344
  2. Brian Cryer
    Replies:
    1
    Views:
    325
    bruce barker \(sqlwork.com\)
    Sep 26, 2006
  3. Ben
    Replies:
    2
    Views:
    884
  4. Lawrence D'Oliveiro

    Death To Sub-Sub-Sub-Directories!

    Lawrence D'Oliveiro, May 5, 2011, in forum: Java
    Replies:
    92
    Views:
    2,021
    Lawrence D'Oliveiro
    May 20, 2011
  5. Scott F. Brown

    Slow page loads, possible security issue?

    Scott F. Brown, Oct 21, 2003, in forum: ASP .Net Security
    Replies:
    1
    Views:
    145
Loading...

Share This Page