Code:
protected virtual void OnConnected(EventArgs e)
{
foreach (EventHandler eh in __Connected[Priority.High])
{
try
{
eh(this, e);
}
catch (Exception ex)
{
ReportException(
ex,
new KeyValuePair<string, object>("delegate", eh),
new KeyValuePair<string, object>("Event", "Connected"),
new KeyValuePair<string, object>("param: priority", Priority.High),
new KeyValuePair<string, object>("param: this", this),
new KeyValuePair<string, object>("param: e", e)
);
}
}
ThreadPool.QueueUserWorkItem((WaitCallback)delegate
{
foreach (EventHandler eh in __Connected[Priority.Normal])
{
try
{
eh(this, e);
}
catch (Exception ex)
{
ReportException(
ex,
new KeyValuePair<string, object>("delegate", eh),
new KeyValuePair<string, object>("Event", "Connected"),
new KeyValuePair<string, object>("param: priority", Priority.Normal),
new KeyValuePair<string, object>("param: this", this),
new KeyValuePair<string, object>("param: e", e)
);
}
}
ThreadPool.QueueUserWorkItem((WaitCallback)delegate
{
foreach (EventHandler eh in __Connected[Priority.Low])
{
try
{
eh(this, e);
}
catch (Exception ex)
{
ReportException(
ex,
new KeyValuePair<string, object>("delegate", eh),
new KeyValuePair<string, object>("Event", "Connected"),
new KeyValuePair<string, object>("param: priority", Priority.Low),
new KeyValuePair<string, object>("param: this", this),
new KeyValuePair<string, object>("param: e", e)
);
}
}
FreeArgumentResources(e as BaseEventArgs);
});
});
}
FatalExecutionEngineError Managed Debugging Assistant comes up with:
The runtime has encountered a fatal error. The address of the error was at 0x7f578493, on thread 0x14ec. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
(Note 0xc0000005 is ACCESS_VIOLATION).
I doubt I'll get much help but, thoughts?
Also, yes, if I take out the anonymous delegate calls and make those calls inline without a separate thread, the error goes away.