从 gac 加载 dll 会阻止应用程序
在过去的几个月里,我的应用程序变得越来越大。 目前它可以作为 Wpf .EXE 和 XBAP 运行,两者共享相同的代码。 在应用程序中的几个点上,应用程序会锁定。 经过调查,我发现应用程序此时正在从 GAC 加载 dll。
所发生的情况是应用程序启动,这需要几秒钟,然后用户会看到一个登录屏幕。 此时,用户单击“确定”按钮登录应用程序锁定,因为它必须为应用程序的其余部分加载各种 dll。 因为它们是从 UI 线程加载的,所以如果鼠标悬停在“确定”按钮上未完成,所有动画都会停止播放。
一开始只需几秒钟,但目前在某些时候您必须等待几分钟才能继续应用程序。 我认为这是无可例外的。
有没有办法将 dll 的加载从 GAC 转移到另一个线程? 那么可以播放“应用程序加载时请稍候”动画吗? 或者,更好的是,我可以将所需的所有 dll 的加载移至应用程序的启动位置,这样工作时就会减少等待时间。
The last few months my application grew bigger and bigger. It's runnable as Wpf .EXE and XBAP at the moment, both sharing the same code. At a few points in the application, the application locks. After invertigating I found out that the application is loading dlls from the GAC at these moments.
What happens is that the application starts, this takes a couple of seconds, and the user is presented with a logon screen. At the moment the user click the OK button to logon the application locks, because it has to load all kinds of dlls for the rest of the application. Because they're loaded from the UI thread all animations stop playing, event the mouseover of the OK button doesn't finish.
It started out as seconds, but at the moment at some points you'll have to wait a couple of minutes before the app continues. I think it's unexceptable.
Is there a way to move the loading of dlls from the GAC to another thread? So a "Please wait while application is loaded"-animation can be played? Or, even better, can I move the loading of all dlls needed to the start of the app, so there would be less waiting going on when working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的(至少“秒”;不确定它是否会缩放到“分钟”) - 在登录屏幕上,只需启动一个工作线程(可能使用
ThreadPool
)来执行需要这些程序集的操作。 这将导致它们加载...您现在已脱离 UI 线程,在用户键入密码时加载程序集。
Yes (for "seconds" at least; not sure it scales to "minutes") - at the login screen, just spin up a worker thread (perhaps with
ThreadPool
) that does something that requires those assemblies. This will cause them to load...You are now off the UI thread, loading your assemblies while the user types their password.