[英]VSTO splash screen or progress bar
我有一个正在做的项目
Microsoft VSTO (office 2013 excel)
我有某些事情可能需要 10 秒钟才能拨打电话。
理想情况下,我想显示一个进度条或一些状态......经过大量搜索后,我找到了一篇标题为:
如何为 VSTO 应用程序创建启动画面窗口? http://www.datazx.cn/Fv7p5a/xw/oa2v/2q7xs6/mcccjfti-988m-f8r8-8d44-bstb4rfsi4xm23rsdfd.html
所以我开始以一种形式创建这段代码,但后来我意识到我需要在我的方法中调用它并真正附加事件等......
文章说
"display a modal form on a background thread" What is the best way to do this?
我发现在主线程上使用 modal less 形式更容易,到目前为止还没有看到 modal less 方法的任何问题。 类似于下面的代码
var splashWindow = new SplashWindow();
splashWindow.Show();
splashWindow.SetMessage("Starting please wait...");
DoSomeWork(splashWindow);
splashWindow.Close();
接下来您将看到我在 C# 中为 Excel-VSTO 编写启动画面的方法。 我的 Excel 文件已启用宏 (.xlsm)。 这些是步骤:
public partial class ThisWorkbook
{
SplashScreen SC = new SplashScreen();
private async void ThisWorkbook_Startup(object sender, System.EventArgs e)
{
SC.Show();
await Task.Delay(3500);
SC.Close();
more code...
}
}
请注意,我在子例程中添加了async一词,这一点很重要。
private void ThisWorkbook_Startup(object sender, System.EventArgs e)
我希望这是非常有用的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.