protected virtual void OnEvent(EventHandler<ConnectionEventArgs> handler, ConnectionEventArgs e)
{
if (handler != null)
{
foreach (EventHandler<ConnectionEventArgs> singleCast in handler.GetInvocationList())
{
ISynchronizeInvoke syncInvoke = singleCast.Target as ISynchronizeInvoke;
try
{
//This code is to make the raising of the event threadsafe with the UI thread.
if (syncInvoke != null && syncInvoke.InvokeRequired)
{
syncInvoke.BeginInvoke(singleCast, new object[] { this, e });
}
else
{
singleCast(this, e);
}
}
catch (Exception ex)
{
if (CrashOnException)
{
throw;
}
else
{
if (e != null)
{
RaiseExceptionEncountered(ex, e.ID);
}
else
{
RaiseExceptionEncountered(ex, Guid.Empty);
}
}
}
}
}
}
protected virtual void OnEvent(EventHandler<ExceptionEventArgs> handler, ExceptionEventArgs e)