如何处理意外断开连接
我有一个关于 .NET 远程处理最佳实践的问题。代码很臭,我需要做一些重构。
事情是: 我有多个从 MarshalByRefObject 派生的类,它们的数据在客户端软件中使用。 一旦服务器断开连接,我就会收到 RemotingException。
这样做的坏处是:我对所有 MarshalByRefObjects 的引用遍布各处(包括但不限于 GUI),并且在断开连接时,异常会出现在我的代码中的任何位置。
显然我想在一个地方处理这些异常。有这方面的最佳实践吗?
本质上,我想为客户端组合某种“离线”模式
I've got a question concerning best practices with .NET remoting. The code is smelly and I need to do some refactoring.
The thing is:
I've got multiple classes that derive from MarshalByRefObject and their data is used in the client software.
Once the server disconnects I get RemotingException.
The bad thing about this is: My references to all the MarshalByRefObjects are all over the place (including but not limited to the GUI) and upon disconnection the exception turns up anywhere in my code.
Obviously I'd like to handle those exceptions in one place. Are there any best practices for this?
Essentially, I'd like to put together some sort of "offline"-mode for the client
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用代理设计模式设法解决这个问题
Managed to solve this problem with the use of Proxy Design Pattern