I\'ve been dealing with a strange application hang in my clients installations.
After trying several things i reached the conclusion that without a dump it won\'t work.
So I
Following Vlad code, I have found a way to unsubscribe the system events on all objects subscribed out of the main UI thread.
This code works for me and it is solving years of pain dealing with systemevents:
public static void UnsubscribeSystemEvents()
{
try
{
var handlers = typeof(SystemEvents).GetField("_handlers", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
var handlersValues = handlers.GetType().GetProperty("Values").GetValue(handlers);
foreach (var invokeInfos in (handlersValues as IEnumerable).OfType