Interrrupt Subroutine Execution / Click Event

digioz

Newcomer
Joined
Oct 12, 2005
Messages
18
Location
Chicago, IL
Hi,

I am looking for a way to stop / interrupt the execution of a subroutine on a form, based on an even that fires. So basically:

1. User clicks on a button.
2. Button calls a function or subroutine.
3. Event fires on the form.
4. Event stops the execution of the function or subroutine regardless of the stage of the execution the routine is in.
5. The form does NOT close and the data in controls on the form as well as instances of initialized objects remain.

Can anyone think of a way to do this? Maybe using some sort of a signal interrrupt or signal handling?


Thanks,
Pete
 
You could have the button launch a thread to perform the work and when the event fires it terminates the thread. Alternatively the function could poll a variable to see if it should continue or stop and have the event simply set this flag.
 
I didn't explain it well. Here is some more information :

1- Application starts in a Sub Main and initializes a main portal form and launches it.
2- The portal form contains panels, which are populated by other sub-forms.
3- The sub form inside the panel calls a subroutine, let's call it "A".
4- Subroutine A uses a connection object "C" that is always connected to the server to send XML messages.
5- There is a "Send" function inside of the connection object C which I want to break out of. This function sends an XML string to the server and receives a response from it.

What I am trying to do is to break out of subroutine "A" without modifying the logic of it (since in reality there are around 500 + other forms that have a subroutine similar to "A" that calls the connection object's Send Function).

If I break out of the Send function, the function return a Null value breaking the code in subroutine "A", and I don't want to have to modify subroutine "A". I realize ideally I would want to modify my calling subroutine to check for a return message of Null and exit out without continuing, but rewriting every single one of those calling subroutine would be a massive undertaking. Also, each subform expects a different set of XML tags in the return, so I can't just return an empty string or a generic one for all of them.

Thanks,
Pete
 
Back
Top