如何确保 Silverlight OOB 应用程序只有一个实例?
有没有办法确保仅运行受信任的 Silverlight 4 Out Of Browser 应用程序的桌面版本的单个实例?
或者我是否需要通过创建某种粗略的互斥体来手动强制执行此操作?
如果我必须自己强制执行此操作,我会考虑在独立存储中创建一个文件作为锁,然后在退出时将其删除。我会在启动时检查此文件是否存在,以防止打开后续实例。 显然,我需要一种方法来处理应用程序崩溃或以其他方式退出,以防止锁定文件被删除。我的本能是让文件超时,因此如果文件已经超过一定时间则忽略它。不幸的是,该应用程序可以播放电影,因此在正常情况下它可能会运行几个小时。在这种情况下,几个小时的锁定超时不太可能受到任何用户的欢迎。还有更好的解决方案吗?
Is there a way to ensure that only a single instance of the desktop version of a trusted Silverlight 4 Out Of Browser app will run?
Or do I need to manually enforce this through the creation of a crude mutex of some sort?
If I must enforce this myself, I'd look at creating a file in isolated storage as a lock and then deleting it on exit. I'd check this files existence on launch to prevent opening a subsequent instance.
Obviously I'd need a way to handle the app crashing or exiting some other way that prevents the lock file from being deleted. My instinct would be to have a timeout on the file and so ignore it if it's over a certain period of time old. Unfortunately, the app plays movies so it's likely it will run for several hours under normal circumstances. A lock timeout of a few hours isn't likely to be popular with any users in this situation. Are there any better solutions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论