|
| On Error Resume Next |
|
|
|
|
| Messages |
|
Related Types |
This message was discovered on microsoft.public.dotnet.languages.csharp.
| Brandon J Gross |
| GOOD ANSWER |
Is there something comparable in C#?
Thanks,
Brandon
--
---------------------------------------------------------------------------- ----- Brandon J. Gross Accenture - C&HT(Communications and High Tech) IM: Click here to reveal e-mail address Email: Click here to reveal e-mail address Email: Click here to reveal e-mail address
|
|
|
| |
|
|
| |
| |
| Fadi Zeidan |
| GOOD ANSWER |
No there is not. I believe On Error Resume Next still exists in VB.Net because current VBers complained and wanted it in there. You really should use a structured error handling rather than a GoTo, it takes getting used to but it is much better method.
fadi
" Brandon J Gross" <Click here to reveal e-mail address> wrote in message news:unznZKlkBHA.3940@tkmsftngp04... [Original message clipped]
|
|
|
| |
|
|
| |
| |
| Jonathan Allen |
| GOOD ANSWER |
Most old VB code cannot be converted without the use of the On Error commands. Hence its inclusion in VB.Net.
Fortunately, most of the VB programmers I've talked to are dead set against using it in new projects.
-- Jonathan Allen
"Fadi Zeidan" <Click here to reveal e-mail address> wrote in message news:ed9x6glkBHA.444@tkmsftngp03... [Original message clipped]
|
|
|
| |
|
|
| |
| |
| Brandon Gross |
| GOOD ANSWER |
Wow that got some fiery responses.
I do not wish to "write crappy code."
The problem is I have a routine that pushes information out to servers (jobs to be more direct). The user has the option to select multiple servers and push a tool out to the servers. Each tool push is a single call to a sproc. My problem is this, I wish the tools to be pushed out to the servers via a loop but I do not wish to report errors until all the servers that have been selected to receive the push actually do so (i.e. I would like to show success/failures in a cumulative nature after the procedure has been intiated). The reasoning behind this is that a failed push is likely and should not force the whole action to fail.
Thanks,
Brandon
------------------------------- Brandon J. Gross Click here to reveal e-mail address
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
|
|
|
| |
|
|
| |
| |
| Ed Stegman |
| GOOD ANSWER |
I didn't figure you did. Sorry if it sounded that way.
How about something like this aircode then? //assumes collection of servers of some kind. Tweak to fit. int nServers = servers.Count; bool[] result = new bool[nServers]; for (int i = 0; i < nServers; i++){ try{ DoWork(servers[i]); } catch (Exception e){ result[i] = false; //could log failure here or whatever using e continue; //skips to next iteration. } result[i] = true; }
for (int i = 0; i < nServers; i++) Console.WriteLine("Was server #{0} successful? {1}", i, result[i] );
Keep Smilin' Ed Stegman
"Brandon Gross" <Click here to reveal e-mail address> wrote in message news:#WLuAmKlBHA.1688@tkmsftngp03... [Original message clipped]
|
|
|
| |
|
|
| |
| | |
| |
| Brandon Gross |
| GOOD ANSWER |
I did find one issue with your example, Ed. You cannot dynamically set an array size using a variable other than a constant (i.e. the size needs to be known at design time). The ArrayList object is what I choose to overcome this limitation.
Thanks,
Brandon ------------------------------- Brandon J. Gross Accenture Click here to reveal e-mail address
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
|
|
|
| |
|
|
| |
|
|
|
|
|
| |
| Ed Stegman |
| GOOD ANSWER |
If you want to write crappy code that ignores exceptions, you should switch to VB. It's designed to let you shoot yourself in the foot faster than you can in C# [1] ;-))
If you find yourself thinking you need to ignore an exception (or a whole block of them, which is what On Error Resume Next does), why not post what you are trying to do and get some help in restructuring your algorithm? 99.9% of the time there will be a better way to do things, and it can help to have a few extra sets of eyes looking at it.
If you don't want to switch to VB, but still insist on not handling exceptions, you can always do this: [1] C# equiv of On Error Resume Next try{ //One line of crap code here that you will never know is failing. }catch {}
try{ //Next line of crap code here that you will never know is failing. }catch {}
Keep Smilin' Ed Stegman
" Brandon J Gross" <Click here to reveal e-mail address> wrote in message news:unznZKlkBHA.3940@tkmsftngp04... [Original message clipped]
|
|
|
| |
|
|
| |
|
|
|
|
|
|
|
|
BootFX
Reliable and powerful .NET application framework. |
|
|
|
|
|
|