I have this code that runs in parallel with my Form1 class code. The Global.Launcher turns into a true statement after a button is clicked from my Form class. When I run this code, I'm unable to click the add-in (Where the button is located) on Project (Basically Frozen) due to the infinite loop since I can't access the button. Is there a workaround for this? In short, I do not want to run any code in this class until after I press the button on the add-in form. Thanks in advance.
    public partial class ThisAddIn
    {
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            this.Application.NewProject += new Microsoft.Office.Interop.MSProject._EProjectApp2_NewProjectEventHandler(Application_NewProject);
            void Application_NewProject(Microsoft.Office.Interop.MSProject.Project pj)
            {
                while(Global.launcher == false)
                {
                }
                System.Diagnostics.Debug.WriteLine("Starting to run code: ");
            }
        }
        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
        }
        #region VSTO generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InternalStartup()
        {
            this.Startup += new System.EventHandler(ThisAddIn_Startup);
            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
        }
        #endregion
    }
}
 
    