private static void ConnectUnhandledExceptionEvents(global::HockeyApp.Android.CrashManagerListener listener = null)
        {
            if (connectedToUnhandledExceptionEvents)
            {
                HockeyLog.Debug("Crash Manager has already been registered.");
                return;
            }

            lock (crashManagerLock)
            {
                if (connectedToUnhandledExceptionEvents)
                {
                    HockeyLog.Debug("Crash Manager has already been registered.");
                    return;
                }
                ;

                TraceWriter.Initialize(listener);

                AndroidEnvironment.UnhandledExceptionRaiser += (sender, e) => TraceWriter.WriteTrace(e.Exception);
                AppDomain.CurrentDomain.UnhandledException  += (sender, e) => TraceWriter.WriteTrace(e.ExceptionObject);
                TaskScheduler.UnobservedTaskException       += (sender, e) => {
                    if (reportUnobservedTaskException)
                    {
                        TraceWriter.WriteTrace(e.Exception, terminateOnUnobservedTaskException);
                    }
                };

                connectedToUnhandledExceptionEvents = true;
            }
        }
 public static void Initialize(global::Android.Content.Context context, string urlString, string appIdentifier, global::HockeyApp.Android.CrashManagerListener listener)
 {
     DoInitialize(context, urlString, appIdentifier, listener);
     ConnectUnhandledExceptionEvents(listener);
 }
 public static void Register(global::Android.Content.Context context, string appIdentifier, global::HockeyApp.Android.CrashManagerListener listener)
 {
     DoRegister(context, appIdentifier, listener);
     ConnectUnhandledExceptionEvents(listener);
 }