如何加快 VS 加载项中 WPF 窗口的打开速度?
我有一个 Visual Studio 加载项,可以打开模式 WPF 窗口。
我的问题是,第一次,窗口需要 4 秒才出现,这对客户端来说显然是一种伤害。 所以我想知道是否有一种方法可以优化它?
是否有某种漂亮的代码可以在加载项启动时(而不是实际使用时)预加载PresentationFramework(或任何减慢速度的内容)?
I have a Visual Studio add-in which opens a modal WPF window.
My problem is that the first time round, it takes 4 seconds for the window to appear which is a clear disservice to the client. So I'm wondering if there is a way to optimize this away?
Is there some kind of nifty code to preload the PresentationFramework (or whatever is slowing the thing down) when the add-in starts, rather than when it is actually used?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要检查 VS 中的输出窗口,看看暂停是否实际上是由于加载尚未加载的 DLL 造成的。 如果是这种情况,那么您可以尝试以下操作:
当应用程序启动时,加载一个空白的隐藏 WPF 窗口并关闭它。
这应该“预加载”演示框架(如果这实际上是问题所在 - 有时很难在这些情况下判断。),这样当您调用所需的窗口时,它就可以打开了。
这不是最好的解决方案,但用户通常可以首先等待 4 秒。
You may want to check your output window in VS to see if the pause is actually from loading DLL's that it didn't have already loaded. If that's the case, then you can try this:
When the application starts, load a blank hidden WPF window and close it.
This should "pre-load" the presentation framework (if that's actually the problem - its sometimes hard to tell with these cases.), so that when you call the needed window its ready to open.
Not the best solution, but users can usually wait 4 seconds in the first place.