473,651 Members | 3,011 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1829
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
4938
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 click a toolbar button that executes the code: application.quit in a module in my Acesss project. - My Access project closes. Now there are TWO instances of MSACCESS.EXE showing up in the Windows Task Manager Processes window, my cursor is...
3
2030
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 the interest of complete disclosure, mda B also references mda C). This application has always closed in the mvps time-honored method of calling Application.Quit on the Unload event of the switchboard.
4
2813
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 can I handle the event for that button. Thanks in Advance
2
3203
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 their machine, and it is opened in the appropriate Office app. I've hooked the various BeforeSave events to let me know if/when they've made modifications to the file, so I can mark it as dirty. However, I would like to know when the Office...
6
5291
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 = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem); oMail.HTMLBody = "SOME HTML TEXT HERE"; oMail.Display(oApp); oMail.Close(Outlook.OlInspectorClose.olDiscard);
4
2357
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 which I mean here. Just for a moment, let's just take one definition for one of the
0
3983
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 WordDoc.Close(ref _newMissing, ref _newMissing, ref _newMissing); WordApp.Application.Quit(ref _notTrue, ref _newMissing, ref _newMissing);
16
8381
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 have 3 methods A, B and C. All of them shall be run threaded (I/O tasks) and one after another. I can create a thread and schedule one method just like:
9
21386
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 compacting), if you use the following code on an "Exit Application" type button, the compacting on close won't fire: Application.Quit acQuitSaveNone however, if you use:
0
8361
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8278
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
8807
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7299
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
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
4144
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
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
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
1588
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.