Avoid throwing exception from asynchronous delegate.

I am using delegate to invoke asyncronous call of the function. Sometimes the function can throw exception.
As described in thread Re: exception handling with events , article "Handling Exceptions Thrown from an Asynchronous Delegate"(and in many other places)
"You should call EndInvoke in a try/catch block to catch any exceptions
your asynchronous method threw". I followed the same approach in my Asynchronous long-running tasks in ASP.NET application  
The code is like the following:
 RecalculateDelegate dlgt = new RecalculateDelegate(CallbackWithException);
IAsyncResult asyncResult = dlgt.BeginInvoke(params, null, asyncState); 
 try
{
bool bRet=dlgt.EndInvoke(asyncResult);// 
  if (bRet == false
  {
    Debug.Assert(false, "To Implement"); 
  }
}
 
catch (Exception exc)
 {
   EventSources.RaiseErrorMessage(EventSources.MyEventSource, message, ExceptionSeverity.Error, exc);
  } 
However when I tried to debug, VS showed me the message "An exception of type 'xxx' occurred in xxx.dll but was not handled in user code". After this it also not executing catch block, but hangs for a while and then timeouts in the client(the code is located in .Net Remoting server method.)

 In production (Release mode without any debugging) it seems  that catch block is invoked(I can see event log entries).

 The discussion Exceptions in asynchronous delegates  suggests to change VS setting to avoid the message. However I feel that more reliable approach will be catch (and log) all exceptions in the delegate function to ensure that they are not thrown asyncronously.

 Related posts:
Strange: calling EndInvoke from an AsyncCallback - why UnhandledException -too long and WinForms specific.

Helper functions to get last element in collection

Below are couple simple helper functions to get last element in collection:


 public static Object LastElement(Object[] myArr)
        {
            if( IsNullOrEmpty(myArr))
            {
                return null;
            }
            return myArr[myArr.Length-1];
        }


        public static DataRow GetLastRow(DataTable tbl)
        {
            if (tbl == null) { throw new NullReferenceException("tbl is null"); }
            if (tbl.Rows.Count == 0)
            {
                return null;
            }
            return tbl.Rows[tbl.Rows.Count - 1];
        }

«December»
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910