|
-
Jun 15th, 2007, 11:14 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Interrupt a Function
How can I stop another function in the middle no matter which line it's at? Can I use something like Exit Sub or Exit Function on another function? Thanks
-
Jun 15th, 2007, 11:32 AM
#2
Re: Interrupt a Function
Nope. Application code runs in a single thread; no two functions will execute concurrently.
-
Jun 15th, 2007, 11:40 AM
#3
Re: Interrupt a Function
You can only do that by making a global boolean variable that when set to True causes all functions to halt. Of course, functions must have a check for that global variable, preferably at every long lasting loop.
-
Jun 15th, 2007, 11:42 AM
#4
Thread Starter
Hyperactive Member
Re: Interrupt a Function
Okay, so the only "real" way is to run a multithreaded application? I've heard that it's possible to create a multithreaded VB application but it would be very unstable. Why is that?
So, the best way to solve my problem would be to put something like:
If Stop = True Then Exit Function
after each line in the function?
-
Jun 15th, 2007, 11:46 AM
#5
Re: Interrupt a Function
You can't create truely multithreaded applications in VB because of the thread-local storage used by the COM. Because application code executes in a single thread you won't run into the situation where you would need to stop another method mid-execution.
If you describe your problem in more detail and give an example of where you think this is required then we can suggest an appropriate solution.
-
Jun 15th, 2007, 11:53 AM
#6
Thread Starter
Hyperactive Member
Re: Interrupt a Function
Oh, never mind. Actually, I will use something like:
If Stop = True Then Exit Function
but I just looked at the code and I won't need to put it after EVERY line. It would just be a couple of lines.
-
Jun 15th, 2007, 05:20 PM
#7
Re: [RESOLVED] Interrupt a Function
Stop is a reserved word - use something else or you'll get compile errors.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Jun 15th, 2007, 05:28 PM
#8
Thread Starter
Hyperactive Member
Re: [RESOLVED] Interrupt a Function
Yeah, I didn't use that exact code, anyway. Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|