c# - 在窗体类中单击按钮后如何执行加载项类中的代码?
问题描述
我有这个代码与我的 Form1 类代码并行运行。从我的 Form 类中单击一个按钮后, Global.Launcher 变成了一个真实的声明。当我运行此代码时,由于无限循环,我无法单击 Project(基本冻结)上的加载项(按钮所在的位置),因为我无法访问该按钮。有解决方法吗?简而言之,在按下加载项表单上的按钮之前,我不想运行此类中的任何代码。提前致谢。
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
}
}
解决方案
推荐阅读
- c# - 让多节车厢的火车在贝塞尔路径上行驶
- algorithm - 算法可以是一条指令吗?
- html - 阻止网络刮刀在 R 中显示 404 错误
- android - 如何通过 Xamarin 表单中的依赖服务更新视图模型?
- azure-keyvault - 尝试将自定义角色“秘密读者”分配给 Azure Key Vault 的对象 ID 时出错
- javascript - javascript 如何在不影响键的情况下将对象推入数组?
- php - APT 说“软件包没有安装候选者”虽然它显示在 apt 列表中
- javascript - 我们是否在使用 await 的异步函数上使用 await?
- c++ - C++:程序在向量填充和搜索期间失败
- docker - Helm, Docker - 添加 repo 在 docker 容器内失败但在外部工作