473,405 Members | 2,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

quit method execution on event

Usually when a method is executing and an event occurs the event handler
executes then the thread is returned to the original method.

I have a case where I want my event handler to cancel execution of any
existing methods in process. Is there a way?
Oct 14 '07 #1
4 1818
Ok, the parent method is any one of several procedures each of which access a
function (in another class) with a try-catch block. The catch block triggers
an event which is handled in the main class with an error procedure. When the
error procedure completes the parent method resumes.

I could set a Boolean "IsErrror" variable to true and include a conditional
in each of the many possible parent methods and abort the method if
ISError==true, but that is inelegant. I was hoping there was some way to
abort the sender method from the error event handler.

Oct 14 '07 #2
mr peanut wrote:
Ok, the parent method is any one of several procedures each of which access a
function (in another class) with a try-catch block. The catch block triggers
an event which is handled in the main class with an error procedure. When the
error procedure completes the parent method resumes. [...]
So you've got an event that is raised as part of your error handling?

Why not just rethrow the exception after you've done your own local
error handling?

Pete
Oct 14 '07 #3


"Peter Duniho" wrote:
mr peanut wrote:
Ok, the parent method is any one of several procedures each of which access a
function (in another class) with a try-catch block. The catch block triggers
an event which is handled in the main class with an error procedure. When the
error procedure completes the parent method resumes. [...]

So you've got an event that is raised as part of your error handling?

Why not just rethrow the exception after you've done your own local
error handling?

Pete
Pete;

Sorry I'm so dunderheaded.

If I use this approach will I then need to have a try catch block in each of
the parent procedures?
Oct 15 '07 #4
mr peanut wrote:
[...]
If I use this approach will I then need to have a try catch block in each of
the parent procedures?
That depends on what your intent for the code's behavior is. You
haven't been very specific about what it is exactly you're trying to do,
so it's very difficult to offer any specific advice.

Your previous post seems to imply that you do not want the "parent"
method to continue executing, so based on that I'd say no, you would not
want to catch the exception in the "parent" method.

Now, whether you want an exception handler in the code that calls the
"parent" method, I can't say. It really depends on what exactly it is
you are trying to accomplish. But generally speaking, if you want a
section of code to stop executing, execution still has to resume
_somewhere_, or else the thread that's currently executing has to itself
exit.

Without knowing exactly how you want your code flow to be adjusted
according to the error, I can't really say what the best way to do that is.

Pete
Oct 15 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Lauren Quantrell | last post by:
Running Access2000 ADP Project/MSDE on Windows XP... - I Open my Access ADP project. In the Windows Task Manager Processes window MSACCESS.EXE shows up. - I don't do anything else in Access. - I...
3
by: downwitch | last post by:
Greetings, I have an application which has recently gone from being one big piece of front-end code to being three, i.e. an mdb A that references an mda B and an mda C. (For what it's worth, in...
4
by: Xarky | last post by:
Hi, I have a program, that makes use of threads. Now when I quit the program from the upper right button of the window, the threads are not terminated and the program is still is running. How...
2
by: hsuntn | last post by:
I'm working with Office Application objects in a client/server WinForm application which allows the user to access remotely stored files. When the user opens the remote file, it is downloaded to...
6
by: Max | last post by:
I have the following code on a form that launches Microsoft Outlook and creates a new email message for the user: Outlook.Application oApp = new Outlook.Application(); Outlook.MailItem oMail...
4
by: Michael | last post by:
Hi, I'm having difficulty finding any previous discussion on this -- I keep finding people either having problems calling os.exec(lepev), or with using python's exec statement. Neither of...
0
by: Alan T | last post by:
I tried to close the word document object and word application: private Interop.Word.Application WordApp; private Interop.Word.Document WordDoc; // close word and quit word application ...
16
by: Paul Schwann | last post by:
Hi group, I am relatively new to C# (although I have a lot of programming excperience in other languages like Java and C). Currently I am searching for a solution to this problem: Suppose you...
9
by: Andy | last post by:
Just noticed something interesting in the above. If you have your program file set to "Compact on Close" in access 2007 (which is desirable when you have a larger program that frequently needs...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.