473,800 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Try Catch...need my brain rattled.

Trying to get back into .net again after being out of it for a while.

I'm trying to figure out the proper way to handle multiple events via a try
catch.

What I'm confused about is the proper method to handle, say, 3 separate
events: A, B, and C. I only want all 3 to execute if all 3 can successfully
execute.

Is that what a try-catch is for, or is a try/catch mainly for individual
events?

Is there a best-practice way to handle checking for 3 separate events and
only executing all 3 only if they all can execute without error?

-Darrel

Jul 22 '08
11 1491
What do these functions actually do?

Well my real world example was a file system update + a DB update. In
reality, the try-catch will be fine, as if the DB fails then the page likely
isn't loading at all, so I can mainly just check for the file system
function in the try-catch. If it fails, the DB update doesn't happen.

But then that got be thinking hypothetically of exactly what you decribe:
It sounds like what you are after is a transactional system whereby the
effects of A, B and C must only be commited if all three are successful.
Indeed, at that point, hopefully I'd be doing everything within SQL and
leverage transactions.

Otherwise, as Goran states, I write a bunch of code. ;o)

-Darrel
Jul 23 '08 #11
You can't do that using merely a try...catch. You either need a way to
tell if a method will be able to execute before actually executing it,
or a way to rollback the method.
Thanks! That confirms my line of thinking!

_Darrel
Jul 23 '08 #12

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

Similar topics

2
2138
by: Rahul | last post by:
Hi, I have a little program as follows : =================== STARTS HERE ================ #include <stdio.h> void f (unsigned long); int main() {
23
2605
by: Adam | last post by:
I am coding a microkernel based off of Tanebaum's theroy. For Isis to be extensible, fast, and secure, it has been decided it will be a microkernel. Not in the old Mach sense of the word, but in the size of the entire project. It is a microkernel, that will limit interprocess communication. But as Tanenbaum says, you learn nothing by reading theroy alone. The code should be self-explaintory. Another reason I choose the microkernel method...
3
1699
by: RC | last post by:
Dear Dudes, I post this in multiple groups for opening brain storm. Sometime I need to query the data from database server then display them into user's browser in HTML <table>. But if the <table> is very LARGE, let's say 20 columns, hundreds rows. Usually you have header <th> tags on 1st (top) row and 1st (most left) column. For a such LARGE <table>. you really want:
28
3816
by: gnuist006 | last post by:
I have some code like this: (if (test) (exit) (do something)) or (if (test)
7
1267
by: Lloyd Sheen | last post by:
I noticed a thread a few days ago about the use of Try.. Catch versus testing variables etc and had in my mind to test exactly what the impact was. Its a mind boggler. I created a small windows app that executed two subroutines. The first simply created an object which does not implement an interface and attempts to assign that object to an variable of the interface type. This is done in a try ... catch block.
0
9690
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...
1
10253
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10033
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...
0
9085
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...
0
5471
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
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
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
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
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.