473,841 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_TextCha nged(sender, e)
Session("GRN") = ""
Exit Sub
End If

The txtScan_TextCha nged 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 2474
"Kathy Burke" <ka**********@a ttbi.com> wrote in message
news:OY******** ******@TK2MSFTN GP09.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_TextCha nged(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**********@a ttbi.com> wrote in message
news:OY******** ******@TK2MSFTN GP09.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_TextCha nged(sender, e)
Session("GRN") = ""
Exit Sub
End If

The txtScan_TextCha nged 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
1507
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 sn="1112" start="07/15/03" end="07/16/03" />
4
4943
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 terminate this thread by calling the "Abort" funcion. But the thread does not terminate and after the form is closed this thread keeps running at blocked state. Basically the application keeps running because this thread does not terminate while...
15
1402
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 when unstressed, but fails under stress. Well...I just noticed short mention in Prosise's book, of all places, re threading. He indicated that the behavior of unmanaged code within managed threads is not predictable. I had thought that the...
3
390
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 (all session's time out) i understand the application stops until another user comes to the site. if my thread is doing something will it be forced to stop or will the Application stop after the thread is done.
4
1698
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 page's IsPostBack property... For exmple.... when I click the submit button which is in usercontrol, ASPX page should
2
1152
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" rather than "Small Fonts" I get an error : "An unhandled exception of type 'System.NullReferenceException' occurred in Unknown Module. Additional information: Object reference not set
3
13792
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
2084
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 second user in succession I get permission denied when I try to select from a table that the user does have access to. Following is a cut and paste of two sessions showing what I mean (with certain details masked out). defender# psql db1-U...
1
7279
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 following "LOAD". Expected tokens may include: "QUERY". SQLSTATE=42601 db2 query load terminate DB21034E The command was processed as an SQL statement because it was
0
9703
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10302
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7846
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7024
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5691
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4081
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3140
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.