예제 #1
0
 /// <summary>
 /// Inserts empty records into client client database, files table
 /// </summary>
 /// <param name="from"></param>
 /// <param name="to"></param>
 public static void InsertFileAsync(int countryId, string[] siteCodes, ThreadExceptionEventHandler error = null)
 {
     foreach (var siteCode in siteCodes)
     {
         SQLWorker.Default.Add(CreateInsertFileCommand(countryId, siteCode), null, error);
     }
 }
    private static T CreateFormAndStartMessagePump <T>(
        Func <T> createForm,
        ThreadExceptionEventHandler onThreadException,
        UnhandledExceptionEventHandler onDomainException,
        bool isBackground,
        string name) where T : Form
    {
        var latch  = new ManualResetEvent(false);
        T   form   = null;
        var thread = new Thread(ts =>
        {
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            Application.ThreadException += onThreadException;
            AppDomain.CurrentDomain.UnhandledException += onDomainException;
            form = createForm();
            latch.Set();
            Application.Run();
        })
        {
            IsBackground = isBackground,
            Name         = name
        };

        thread.SetApartmentState(ApartmentState.STA);
        thread.Start();
        latch.WaitOne();
        return(form);
    }
예제 #3
0
        public static void RegisterApplicationThreadExceptionHandler(this ExceptionlessClient client)
        {
            if (_onApplicationThreadException == null)
            {
                _onApplicationThreadException = (sender, args) => {
                    var contextData = new ContextData();
                    contextData.MarkAsUnhandledError();
                    contextData.SetSubmissionMethod("ApplicationThreadException");

                    args.Exception.ToExceptionless(contextData, client).Submit();
                }
            }
            ;

            try {
                Application.ThreadException -= _onApplicationThreadException;
                Application.ThreadException += _onApplicationThreadException;
            } catch (Exception ex) {
                client.Configuration.Resolver.GetLog().Error(typeof(ExceptionlessClientExtensions), ex, "An error occurred while wiring up to the unobserved task exception event.");
            }

            // make sure that queued events are sent when the app exits
            AppDomain.CurrentDomain.ProcessExit += (sender, args) => {
                client.ProcessQueue();
            };
        }
        public static void UnregisterApplicationThreadExceptionHandler(this ExceptionlessClient client) {
            if (_onApplicationThreadException == null)
                return;

            System.Windows.Forms.Application.ThreadException -= _onApplicationThreadException;
            _onApplicationThreadException = null;
        }
예제 #5
0
 /// <summary>
 /// Inserts file asynchronously
 /// </summary>
 /// <param name="fileName"></param>
 /// <param name="clientID"></param>
 /// <param name="batchID"></param>
 /// <param name="countryCode"></param>
 /// <param name="fileID"></param>
 /// <param name="relatedID"></param>
 /// <param name="siteCode"></param>
 /// <param name="comment"></param>
 /// <param name="retailerID"></param>
 /// <param name="voucherID"></param>
 /// <param name="voucherImage"></param>
 /// <param name="barCodeImage"></param>
 /// <param name="voucherData"></param>
 /// <param name="dateScanned"></param>
 /// <param name="error"></param>
 public static void UpdateFileAsync(
     int clientID,
     int countryID,
     int retailerID,
     string voucherID,
     string siteCode,
     string comment,
     byte[] voucherImage,
     byte[] barCodeImage,
     DateTime dateScanned,
     ThreadExceptionEventHandler error)
 {
     SQLWorker.Default.Add(
         CreateUpdateFileCommand(
             clientID,
             countryID,
             retailerID,
             voucherID,
             siteCode,
             voucherImage,
             barCodeImage,
             comment,
             dateScanned),
         error);
 }
예제 #6
0
        public static void RegisterApplicationThreadExceptionHandler(this ExceptionlessClient client)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            if (_onApplicationThreadException == null)
            {
                _onApplicationThreadException = (sender, args) => {
                    var contextData = new ContextData();
                    contextData.MarkAsUnhandledError();
                    contextData.SetSubmissionMethod("ApplicationThreadException");

                    args.Exception.ToExceptionless(contextData, client).Submit();
                }
            }
            ;

            try {
                System.Windows.Forms.Application.ThreadException -= _onApplicationThreadException;
                System.Windows.Forms.Application.ThreadException += _onApplicationThreadException;
            } catch (Exception ex) {
                client.Configuration.Resolver.GetLog().Error(typeof(ExceptionlessClientExtensions), ex, "An error occurred while wiring up to the application thread exception event.");
            }
        }
예제 #7
0
        ///// <summary>
        ///// Initializes the application, starts module management remoting server, and launches
        ///// module specified with the command line. If no command line options are given,
        ///// application will load the menu module by default.
        ///// </summary>
        //private void OnMessageThreadStarted()
        //{
        //    IServiceContainer serviceContainer = (IServiceContainer) this.GetService(typeof(IServiceContainer));
        //    this.PublishServices(serviceContainer, false);
        //    this.StartRemotingServer(3);
        //    this.StartInternal(ApplicationManager.commandLineArguments);
        //}

        /// <summary>
        /// Starts unhandled exception handler
        /// </summary>
        private static void AttachExceptionHandler()
        {
            if (ApplicationManager.threadExceptionEventHandler == null)
            {
                ApplicationManager.threadExceptionEventHandler    = new ThreadExceptionEventHandler(ApplicationManager.Application_ThreadException);
                System.Windows.Forms.Application.ThreadException += threadExceptionEventHandler;
            }
        }
예제 #8
0
 /// <summary>
 /// Removes unhandled exception handler
 /// </summary>
 private static void DetachExceptionHandler()
 {
     if (ApplicationManager.threadExceptionEventHandler != null)
     {
         System.Windows.Forms.Application.ThreadException -= threadExceptionEventHandler;
         ApplicationManager.threadExceptionEventHandler    = null;
     }
 }
예제 #9
0
 public static Thread ExecAsync(ParameterizedThreadStart start, object state, ThreadExceptionEventHandler onExceptionCallback)
 {
     internalProtectExecuteClass executeClass = new internalProtectExecuteClass(start, state, onExceptionCallback);
     Thread _th = new Thread(executeClass.Execute2);
     _th.IsBackground = true;
     _th.Start();
     return _th;
 }
예제 #10
0
        protected virtual void OnReaderThreadException(ThreadExceptionEventArgs e)
        {
            ThreadExceptionEventHandler handler = ReaderThreadException;

            if (handler != null)
            {
                handler(this, e);
            }
        }
예제 #11
0
        public static Thread ExecAsync(ParameterizedThreadStart start, object state, ThreadExceptionEventHandler onExceptionCallback)
        {
            internalProtectExecuteClass executeClass = new internalProtectExecuteClass(start, state, onExceptionCallback);
            Thread _th = new Thread(executeClass.Execute2);

            _th.IsBackground = true;
            _th.Start();
            return(_th);
        }
예제 #12
0
        private void InitializeComponent()
        {
            this.ServiceName      = "FintraxServiceManager";
            m_ThreadWorker.Info  += new EventHandler <EntryEventArgs <string> >(ThreadWorker_Info);
            m_ThreadWorker.Error += new ThreadExceptionEventHandler(ThreadWorker_Error);
            LogErrorDelegate      = new ThreadExceptionEventHandler(ThreadWorker_Error);

            AppDomain.CurrentDomain.SetData("LogErrorDelegate", LogErrorDelegate);
        }
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// threadexceptioneventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this ThreadExceptionEventHandler threadexceptioneventhandler, Object sender, ThreadExceptionEventArgs e, AsyncCallback callback)
        {
            if (threadexceptioneventhandler == null)
            {
                throw new ArgumentNullException("threadexceptioneventhandler");
            }

            return(threadexceptioneventhandler.BeginInvoke(sender, e, callback, null));
        }
        public static void UnregisterApplicationThreadExceptionHandler(this ExceptionlessClient client)
        {
            if (_onApplicationThreadException == null)
            {
                return;
            }

            Application.ThreadException  -= _onApplicationThreadException;
            _onApplicationThreadException = null;
        }
        public static void UnregisterApplicationThreadExceptionHandler(this ExceptionlessClient client) {
            if (client == null)
                throw new ArgumentNullException(nameof(client));

            if (_onApplicationThreadException == null)
                return;

            System.Windows.Forms.Application.ThreadException -= _onApplicationThreadException;
            _onApplicationThreadException = null;
        }
예제 #16
0
 /// <summary>
 ///     Add an Exception handler for the Adapter thread
 /// </summary>
 /// <param name="handler"></param>
 public static void AddThreadExceptionHandler(ThreadExceptionEventHandler handler)
 {
     Instancied.WaitOne();
     try
     {
         _instance.Invoke(new Action(() => { Application.ThreadException += handler; }));
     }
     finally
     {
         Instancied.Set();
     }
 }
예제 #17
0
        /// <summary>
        /// Removes all receivers from a ThreadExceptionEventHandler delegate chain
        /// </summary>
        /// <param name="delegate"></param>
        public static void RemoveAll(this ThreadExceptionEventHandler @delegate)
        {
            if (@delegate == null)
            {
                return;
            }

            foreach (ThreadExceptionEventHandler del in @delegate.GetInvocationList())
            {
                @delegate -= del;
            }
        }
예제 #18
0
        public static void UnregisterApplicationThreadExceptionHandler(this ExceptionlessClient client)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            if (_onApplicationThreadException == null)
            {
                return;
            }

            System.Windows.Forms.Application.ThreadException -= _onApplicationThreadException;
            _onApplicationThreadException = null;
        }
        public static void RaiseUnhandledException(Exception exception)
        {
            if (exception == null)
            {
                throw new ArgumentNullException("exception");
            }
            ThreadExceptionEventHandler eh = UnhandledException;

            if (eh != null)
            {
                eh(null, new ThreadExceptionEventArgs(exception));
            }
            else
            {
                Environment.FailFast(exception.ToString());
            }
        }
        public static void RegisterApplicationThreadExceptionHandler(this ExceptionlessClient client) {
            if (_onApplicationThreadException == null)
                _onApplicationThreadException = (sender, args) => {
                    var contextData = new ContextData();
                    contextData.MarkAsUnhandledError();
                    contextData.SetSubmissionMethod("ApplicationThreadException");

                    args.Exception.ToExceptionless(contextData, client).Submit();
                };

            try {
                System.Windows.Forms.Application.ThreadException -= _onApplicationThreadException;
                System.Windows.Forms.Application.ThreadException += _onApplicationThreadException;
            } catch (Exception ex) {
                client.Configuration.Resolver.GetLog().Error(typeof(ExceptionlessClientExtensions), ex, "An error occurred while wiring up to the application thread exception event.");
            }
        }
예제 #21
0
        /// <summary>
        ///     Start the Adapter thread
        /// </summary>
        public static void Start(ThreadExceptionEventHandler exceptionEventHandler = null)
        {
            if (_instance != null)
            {
                throw new InvalidOperationException("Adapter already started");
            }

            _exceptionEventHandler = exceptionEventHandler;

            var t = new Thread(RunForm)
            {
                Name = typeof(WindowsAPIAdapter).Name
            };

            t.SetApartmentState(ApartmentState.STA);
            t.IsBackground = true;
            t.Start();
        }
        public static void RegisterApplicationThreadExceptionHandler(this ExceptionlessClient client) {
            if (client == null)
                throw new ArgumentNullException(nameof(client));

            if (_onApplicationThreadException == null)
                _onApplicationThreadException = (sender, args) => {
                    var contextData = new ContextData();
                    contextData.MarkAsUnhandledError();
                    contextData.SetSubmissionMethod("ApplicationThreadException");

                    args.Exception.ToExceptionless(contextData, client).Submit();
                };

            try {
                Application.ThreadException -= _onApplicationThreadException;
                Application.ThreadException += _onApplicationThreadException;
            } catch (Exception ex) {
                client.Configuration.Resolver.GetLog().Error(typeof(ExceptionlessClientExtensions), ex, "An error occurred while wiring up to the unobserved task exception event.");
            }
        }
예제 #23
0
        public void Add(IDbCommand command, EventHandler success, ThreadExceptionEventHandler error)
        {
            Debug.Assert(m_Worker != null, "Worker is not started");
            Debug.Assert(command != null);
            Debug.Assert(command.Connection != null);

            lock (this)
            {
                CommandInfo info = new CommandInfo(command);
                if (success != null)
                {
                    info.Success += success;
                }
                if (error != null)
                {
                    info.Error += error;
                }
                m_Queue.Add(info);
                Monitor.Pulse(this);
            }
        }
예제 #24
0
 /// <summary>
 /// Updates files int database table by concrete values asynchronously
 /// </summary>
 /// <param name="fileName"></param>
 /// <param name="barcode"></param>
 /// <param name="fileId"></param>
 /// <param name="content"></param>
 /// <param name="success"></param>
 /// <param name="error"></param>
 public static void UpdateFileAsync(DbClientVoucher voucher, EventHandler success, ThreadExceptionEventHandler error)
 {
     SQLWorker.Default.Add(CreateUpdateFileCommand(voucher), success, error);
 }
예제 #25
0
        /// <summary>
        /// Initializes TCP channel and starts remoting server. Should only be called once!
        /// </summary>
        private void CreateInterProcessCommunicationServer(int maximumRetries)
        {
            ThreadExceptionEventHandler terminator = new ThreadExceptionEventHandler(Application_FatalError);

            Application.ThreadException += terminator;

            if (Mode == ExecutionMode.Client)
            {
                throw new InvalidOperationException("Server cannot be created in this AppDomain because a client has been created");
            }
            else if (Mode == ExecutionMode.Server)
            {
                return;
            }

            int retryCount = 0;

            try
            {
                Configuration config = Configuration.GetNewInstance();
                while (true)
                {
                    try
                    {
                        IDictionary properties = new Hashtable(3);
                        properties.Add("bindTo", "127.0.0.1");
                        properties.Add("port", config.Settings.FrameworkTcpPort);
                        TcpChannel tcpChannel = new TcpChannel(properties, null, null);
                        ChannelServices.RegisterChannel(tcpChannel, false);
                        //chnl.GetUrlsForUri(RemotingUri)[0];
                        RemotingServices.Marshal(this, GetUniqueRemotingUri(config.ConfigFilePath));

                        // exit retry while loop
                        break;
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message);

                        SocketException sex = ex as SocketException;
                        if (sex != null)
                        {
                            // port already in use
                            if (sex.ErrorCode == 10048)
                            {
                                // increment port number and for retry
                                config.Settings.FrameworkTcpPort += 1;
                                Configuration.Save(config);
                            }
                        }

                        if (++retryCount > maximumRetries)
                        {
                            throw;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new GeneralException("Framework interprocess communication initalization failed. Please restart and try again.", ex);
            }

            Mode = ExecutionMode.Server;
            Application.ThreadException -= terminator;


            // the unhandled exception handler is disabled in debug builds
            AttachExceptionHandler();
        }
예제 #26
0
 /// <summary>
 /// Sets file exported to the client database asynchronously
 /// </summary>
 /// <param name="siteCode"></param>
 /// <param name="success"></param>
 /// <param name="error"></param>
 public static void SetFileExportedAsync(string siteCode, EventHandler success, ThreadExceptionEventHandler error)
 {
     SQLWorker.Default.Add(CreateSetFileExportedCommand(siteCode), success, error);
 }
예제 #27
0
        /// <summary>
        ///     Star the Adapter thread
        /// </summary>
        public static void Start(ThreadExceptionEventHandler exceptionEventHandler = null)
        {
            if (_instance != null)
                throw new InvalidOperationException("Adapter already started");

            _exceptionEventHandler = exceptionEventHandler;

            var t = new Thread(RunForm) {Name = typeof (WindowsAPIAdapter).Name};
            t.SetApartmentState(ApartmentState.STA);
            t.IsBackground = true;
            t.Start();
        }
예제 #28
0
        /// <summary>
        /// Initializes TCP channel and starts remoting server. Should only be called once!
        /// </summary>
        private void CreateInterProcessCommunicationServer(int maximumRetries)
        {
            ThreadExceptionEventHandler terminator = new ThreadExceptionEventHandler(Application_FatalError);
            Application.ThreadException += terminator;

            if (Mode == ExecutionMode.Client)
            {
                throw new InvalidOperationException("Server cannot be created in this AppDomain because a client has been created");
            }
            else if (Mode == ExecutionMode.Server)
            {
                return;
            }

            int retryCount = 0;

            try
            {
                Configuration config = Configuration.GetNewInstance();
                while (true)
                {
                    try
                    {
                        IDictionary properties = new Hashtable(3);
                        properties.Add("bindTo", "127.0.0.1");
                        properties.Add("port", config.Settings.FrameworkTcpPort);
                        TcpChannel tcpChannel = new TcpChannel(properties, null, null);
                        ChannelServices.RegisterChannel(tcpChannel, false);
                        //chnl.GetUrlsForUri(RemotingUri)[0];
                        RemotingServices.Marshal(this, GetUniqueRemotingUri(config.ConfigFilePath));

                        // exit retry while loop
                        break;
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message);

                        SocketException sex = ex as SocketException;
                        if (sex != null)
                        {
                            // port already in use
                            if (sex.ErrorCode == 10048)
                            {
                                // increment port number and for retry
                                config.Settings.FrameworkTcpPort += 1;
                                Configuration.Save(config);
                            }
                        }

                        if (++retryCount > maximumRetries)
                        {
                            throw;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new GeneralException("Framework interprocess communication initalization failed. Please restart and try again.", ex);
            }

            Mode = ExecutionMode.Server;
            Application.ThreadException -= terminator;

            // the unhandled exception handler is disabled in debug builds
            AttachExceptionHandler();
        }
예제 #29
0
 public internalProtectExecuteClass(ParameterizedThreadStart start, object state, ThreadExceptionEventHandler onExceptionCallback)
 {
     _start2 = start;
     _obj2   = state;
     _onExceptionCallback = onExceptionCallback;
 }
예제 #30
0
 public internalProtectExecuteClass(ThreadStart start, ThreadExceptionEventHandler onExceptionCallback)
 {
     _start1 = start;
     _onExceptionCallback = onExceptionCallback;
 }
예제 #31
0
 private void RegisterGlobalExceptionTraps(ThreadExceptionEventHandler handler)
 {
     Application.ThreadException += handler;
     AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
 }
예제 #32
0
 public void Add(IDbCommand command, ThreadExceptionEventHandler error)
 {
     Add(command, null, error);
 }
예제 #33
0
 /// <summary>
 /// Removes unhandled exception handler
 /// </summary>
 private static void DetachExceptionHandler()
 {
     if (ApplicationManager.threadExceptionEventHandler != null)
     {
         System.Windows.Forms.Application.ThreadException -= threadExceptionEventHandler;
         ApplicationManager.threadExceptionEventHandler = null;
     }
 }
예제 #34
0
        /// <summary>
        /// Inserts file by serializetion data saved in a hashtable
        /// </summary>
        /// <param name="serializationData"></param>
        /// <param name="error"></param>
        public static void InsertFileAsync(Hashtable serializationData, ThreadExceptionEventHandler error)
        {
            SqlCommand command = MSSQL.CreateCommand(ConnectionString, serializationData);

            SQLWorker.Default.Add(command, error);
        }
예제 #35
0
        private static void Main()
        {
            Class283.Class284 @class = new Class283.Class284();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            @class.mutex_0                      = null;
            @class.memoryMappedFile_0           = null;
            @class.mutex_1                      = null;
            Thread.CurrentThread.CurrentCulture = (Thread.CurrentThread.CurrentUICulture = Class217.cultureInfo_0);
            Class368 class2 = new Class368(Class291.string_17);

            Class373.Logger = class2;
            Class367 class3 = class2;

            if (Class283.eventHandler_0 == null)
            {
                Class283.eventHandler_0 = new EventHandler <EventArgs25>(Class283.smethod_1);
            }
            class3.LogFileCompressed += Class283.eventHandler_0;
            @class.bool_0             = false;
            @class.action_0           = new Action(@class.method_0);
            @class.bool_1             = false;
            @class.action_1           = new Action(@class.method_1);
            @class.action_2           = new Action(@class.method_2);
            @class.action_3           = new Action <Exception, string>(@class.method_3);
            UnhandledExceptionEventHandler value = new UnhandledExceptionEventHandler(@class.method_4);

            AppDomain.CurrentDomain.UnhandledException += value;
            ThreadExceptionEventHandler value2 = new ThreadExceptionEventHandler(@class.method_5);

            Application.ThreadException += value2;
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            Enum29 @enum = Environment.OSVersion.smethod_0();

            if (@enum > Enum29.const_0 && @enum < Enum29.const_10)
            {
                DialogBox.smethod_3(Class283.string_2, Class283.string_3);
                Application.Exit();
                return;
            }
            try
            {
                try
                {
                    @class.mutex_1 = new Mutex(false, Class283.string_16);
                    if (!(@class.bool_0 = @class.mutex_1.WaitOne()))
                    {
                        Environment.ExitCode = 1;
                        Application.Exit();
                    }
                    else if (Class265.smethod_1(Class283.string_15))
                    {
                        Class283.smethod_0();
                        Environment.ExitCode = 1;
                        Application.Exit();
                    }
                    else if (Class409.Current.Flags.Contains(Class283.string_17))
                    {
                        Environment.ExitCode = 0;
                        Application.Exit();
                    }
                    else if (Class409.Current.Flags.Contains(Class283.string_18))
                    {
                        if (DialogBox.smethod_6(Class283.string_6, Class283.string_7, new Enum39[]
                        {
                            Enum39.const_5,
                            Enum39.const_6
                        }) == DialogResult.Yes)
                        {
                            using (UninstallationCleanUp uninstallationCleanUp = new UninstallationCleanUp())
                            {
                                Application.Run(uninstallationCleanUp);
                            }
                        }
                        Application.Exit();
                    }
                    else
                    {
                        try
                        {
                            @class.mutex_0 = new Mutex(false, Class283.string_15);
                        }
                        catch (Exception ex)
                        {
                            @class.action_1();
                            ex.smethod_0();
                            DialogBox.smethod_4(Class283.string_8, Class283.string_9);
                            Application.Exit();
                            return;
                        }
                        if (!(@class.bool_1 = @class.mutex_0.WaitOne(TimeSpan.Zero, false)))
                        {
                            Class283.smethod_0();
                            Environment.ExitCode = 1;
                            Application.Exit();
                        }
                        else
                        {
                            try
                            {
                                @class.memoryMappedFile_0 = MemoryMappedFile.CreateNew(Class283.string_13, 4L, MemoryMappedFileAccess.ReadWrite);
                            }
                            catch (IOException ex2)
                            {
                                ex2.smethod_0();
                                @class.action_2();
                                if (Marshal.GetHRForException(ex2) == (int)Class265.uint_0)
                                {
                                    Class283.smethod_0();
                                    Environment.ExitCode = 1;
                                    Application.Exit();
                                    return;
                                }
                            }
                            using (Class283.icon_0 = Icon.ExtractAssociatedIcon(Application.ExecutablePath))
                            {
                                Class176 instance = Class176.Instance;
                                DateTime now      = DateTime.Now;
                                if (instance.UpdateStepOn == Enum111.const_6 || (Class110.Instance.ApplicationSettings.UpdateType != Enum78.const_3 && (now - instance.LastCheckedForUpdate).TotalDays >= 14.0))
                                {
                                    bool flag = false;
                                    try
                                    {
                                        using (Updater updater = new Updater(true))
                                        {
                                            Application.Run(updater);
                                            switch (updater.UpdateResult)
                                            {
                                            case Enum43.const_4:
                                            case Enum43.const_6:
                                                flag = true;
                                                break;

                                            case Enum43.const_5:
                                                instance.UpdateStepOn = Enum111.const_0;
                                                flag = true;
                                                Application.Exit();
                                                return;
                                            }
                                        }
                                    }
                                    finally
                                    {
                                        if (flag)
                                        {
                                            instance.LastCheckedForUpdate = now;
                                            instance.method_0();
                                        }
                                    }
                                }
                                try
                                {
                                    using (Class435 class4 = new Class435())
                                    {
                                        EventHandler <EventArgs11> eventHandler = null;
                                        Class283.Class285          class5       = new Class283.Class285();
                                        class5.class284_0 = @class;
                                        class5.class330_0 = new Class330();
                                        try
                                        {
                                            Class435 class6 = class4;
                                            if (eventHandler == null)
                                            {
                                                eventHandler = new EventHandler <EventArgs11>(class5.method_0);
                                            }
                                            class6.DataReceived += eventHandler;
                                            if (@class.memoryMappedFile_0 != null)
                                            {
                                                using (MemoryMappedViewStream memoryMappedViewStream = @class.memoryMappedFile_0.CreateViewStream(0L, (long)Class283.int_0, MemoryMappedFileAccess.ReadWrite))
                                                {
                                                    using (BinaryWriter binaryWriter = new BinaryWriter(memoryMappedViewStream, Class217.encoding_0))
                                                    {
                                                        binaryWriter.Write(Process.GetCurrentProcess().Id);
                                                        binaryWriter.Write(class4.Handle.ToInt64());
                                                    }
                                                }
                                            }
                                            @class.action_0();
                                            bool flag2 = Class409.Current.Flags.Contains("DEBUG");
                                            try
                                            {
                                                if (flag2)
                                                {
                                                    Class335.smethod_0(Class291.DebugLogDirectory);
                                                    Class110.Instance.CreatedFileArchive.method_4(Class335.LogFile);
                                                    Class335.smethod_2(Class283.string_5, false);
                                                    Class335.smethod_2(Class283.string_4, false);
                                                }
                                                Application.Run(class5.class330_0);
                                            }
                                            finally
                                            {
                                                if (flag2)
                                                {
                                                    Class335.smethod_2(Class283.string_5, false);
                                                    Class335.smethod_1();
                                                }
                                            }
                                        }
                                        finally
                                        {
                                            if (class5.class330_0 != null)
                                            {
                                                ((IDisposable)class5.class330_0).Dispose();
                                            }
                                        }
                                    }
                                }
                                finally
                                {
                                    Class110.smethod_1();
                                }
                            }
                        }
                    }
                }
                finally
                {
                    @class.action_0();
                }
            }
            finally
            {
                @class.action_1();
                @class.action_2();
                Application.ThreadException -= value2;
            }
        }
예제 #36
0
 public internalProtectExecuteClass(ParameterizedThreadStart start, object state, ThreadExceptionEventHandler onExceptionCallback)
 {
     _start2 = start;
     _obj2 = state;
     _onExceptionCallback = onExceptionCallback;
 }
예제 #37
0
 internal static void AttachThreadException(ThreadExceptionEventHandler handler)
 {
     System.Windows.Forms.Application.ThreadException += handler;
 }
예제 #38
0
 public internalProtectExecuteClass(ThreadStart start, ThreadExceptionEventHandler onExceptionCallback)
 {
     _start1 = start;
     _onExceptionCallback = onExceptionCallback;
 }
예제 #39
0
 ///// <summary>
 ///// Initializes the application, starts module management remoting server, and launches 
 ///// module specified with the command line. If no command line options are given, 
 ///// application will load the menu module by default.
 ///// </summary>
 //private void OnMessageThreadStarted()
 //{
 //    IServiceContainer serviceContainer = (IServiceContainer) this.GetService(typeof(IServiceContainer));
 //    this.PublishServices(serviceContainer, false);
 //    this.StartRemotingServer(3);
 //    this.StartInternal(ApplicationManager.commandLineArguments);
 //}
 /// <summary>
 /// Starts unhandled exception handler
 /// </summary>
 private static void AttachExceptionHandler()
 {
     if (ApplicationManager.threadExceptionEventHandler == null)
     {
         ApplicationManager.threadExceptionEventHandler = new ThreadExceptionEventHandler(ApplicationManager.Application_ThreadException);
         System.Windows.Forms.Application.ThreadException += threadExceptionEventHandler;
     }
 }
예제 #40
0
 /// <summary>
 ///     Add an Exception handler for the Adapter thread
 /// </summary>
 /// <param name="handler"></param>
 public static void AddThreadExceptionHandler(ThreadExceptionEventHandler handler)
 {
     Instancied.WaitOne();
     try
     {
         _instance.Invoke(new Action(() => { Application.ThreadException += handler; }));
     }
     finally
     {
         Instancied.Set();
     }
 }