By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,759 Members | 1,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,759 IT Pros & Developers. It's quick & easy.

Exception Handling - .Net Runtime Error Unhandled Exceptions

P: n/a
I have built an asychronous TCP Server that uses the thread pool. I have two
levels of exception handling in case the handling of the inner catch block
throws an exception. The outer catch block does nothing put print a string
literal to our logging mechanism. The general structure for this is:

AsyncReceiveCallback
{
try
{
OnReceiveDelegate();
}
catch (SocketException)
{
...
}
catch (ObjectDisposedException)
{
...
}
catch (Exception ex)
{
...
}
}
catch (Exception ex)
{
...
}
}

The OnReceiveDelegate is what handles the application business logic and
this business logic also has exception handling, but in some cases it may not
catch everything. My question here is shouldn't my exception handling in the
AsyncReceiveCallback method catch any unhandled exception returning from the
OnReceiveDelegate method?

Aug 31 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Note: I accidentally left out the top try:

AsyncReceiveCallback
{
try
{
try
{
OnReceiveDelegate();
}
catch (SocketException)
{
...
}
catch (ObjectDisposedException)
{
...
}
catch (Exception ex)
{
...
}
}
catch (Exception ex)
{
...
}
}
"Larry Herbinaux" wrote:
I have built an asychronous TCP Server that uses the thread pool. I have two
levels of exception handling in case the handling of the inner catch block
throws an exception. The outer catch block does nothing put print a string
literal to our logging mechanism. The general structure for this is:

AsyncReceiveCallback
{
try
{
OnReceiveDelegate();
}
catch (SocketException)
{
...
}
catch (ObjectDisposedException)
{
...
}
catch (Exception ex)
{
...
}
}
catch (Exception ex)
{
...
}
}

The OnReceiveDelegate is what handles the application business logic and
this business logic also has exception handling, but in some cases it may not
catch everything. My question here is shouldn't my exception handling in the
AsyncReceiveCallback method catch any unhandled exception returning from the
OnReceiveDelegate method?
Aug 31 '06 #2

P: n/a
Larry,

Yes. It should catch any exception thrown by OnReceiveDelegate. In
fact, it should catch any exceptions thrown by the catch blocks of the
inner try-catch block as well. The only way AsyncReceiveCallback can
throw an exception is if the outer catch block generates it. Are you
observing different behavior?

Brian

Larry Herbinaux wrote:
Note: I accidentally left out the top try:

AsyncReceiveCallback
{
try
{
try
{
OnReceiveDelegate();
}
catch (SocketException)
{
...
}
catch (ObjectDisposedException)
{
...
}
catch (Exception ex)
{
...
}
}
catch (Exception ex)
{
...
}
}
"Larry Herbinaux" wrote:
I have built an asychronous TCP Server that uses the thread pool. I have two
levels of exception handling in case the handling of the inner catch block
throws an exception. The outer catch block does nothing put print a string
literal to our logging mechanism. The general structure for this is:

AsyncReceiveCallback
{
try
{
OnReceiveDelegate();
}
catch (SocketException)
{
...
}
catch (ObjectDisposedException)
{
...
}
catch (Exception ex)
{
...
}
}
catch (Exception ex)
{
...
}
}

The OnReceiveDelegate is what handles the application business logic and
this business logic also has exception handling, but in some cases it may not
catch everything. My question here is shouldn't my exception handling in the
AsyncReceiveCallback method catch any unhandled exception returning from the
OnReceiveDelegate method?
Sep 1 '06 #3

P: n/a
Brian,

Yes we are having some exceptions that cause a .Net Runtime error. We have
at least one general business logic exception that we are looking into, but
we also see it in our production environment when we switch from one DB
Cluster Node to another (not all the time...but this could be to timing
issues...e.g. in the middle of a SQL Request or not when switch occurs).

"Brian Gideon" wrote:
Larry,

Yes. It should catch any exception thrown by OnReceiveDelegate. In
fact, it should catch any exceptions thrown by the catch blocks of the
inner try-catch block as well. The only way AsyncReceiveCallback can
throw an exception is if the outer catch block generates it. Are you
observing different behavior?

Brian

Larry Herbinaux wrote:
Note: I accidentally left out the top try:

AsyncReceiveCallback
{
try
{
try
{
OnReceiveDelegate();
}
catch (SocketException)
{
...
}
catch (ObjectDisposedException)
{
...
}
catch (Exception ex)
{
...
}
}
catch (Exception ex)
{
...
}
}
"Larry Herbinaux" wrote:
I have built an asychronous TCP Server that uses the thread pool. I have two
levels of exception handling in case the handling of the inner catch block
throws an exception. The outer catch block does nothing put print a string
literal to our logging mechanism. The general structure for this is:
>
AsyncReceiveCallback
{
try
{
OnReceiveDelegate();
}
catch (SocketException)
{
...
}
catch (ObjectDisposedException)
{
...
}
catch (Exception ex)
{
...
}
}
catch (Exception ex)
{
...
}
}
>
The OnReceiveDelegate is what handles the application business logic and
this business logic also has exception handling, but in some cases it may not
catch everything. My question here is shouldn't my exception handling in the
AsyncReceiveCallback method catch any unhandled exception returning from the
OnReceiveDelegate method?
>

Sep 4 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.