ACPAddIn.ThisAddIn.InternalStartup C# (CSharp) Method

InternalStartup() private method

private InternalStartup ( ) : void
return void
        private void InternalStartup()
        {
            this.Startup += new System.EventHandler(ThisAddIn_Startup);
            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);

            this.Application.DocumentBeforeClose += new Word.ApplicationEvents4_DocumentBeforeCloseEventHandler(delegate(Word.Document doc, ref bool Cancel)
            {
                handle = (int)GetActiveWindow();

                if (isEnabled)
                {
                    BackgroundWorker b = new BackgroundWorker();
                    b.DoWork += delegate(object sender, DoWorkEventArgs e)
                    {
                        try
                        {
                            // Inform ACP to close the Document
                            logic.closeDestinationDocument(handle);
                        }
                        catch (SocketException e2)
                        {
                        }

                        // Logging for user testing
                        if (isUserActionLogging)
                        {
                            endTestTime = "END TIME," + DateTime.Now.ToString("HH:mm:ss") + "\r";
                            writeToFile(logContent);
                        }
                    };
                    b.RunWorkerAsync();
                }
                else
                {
                    if (checkServerStatusTimer != null)
                    {
                        checkServerStatusTimer.Stop();
                    }
                }

            });
        }