如何处理意外断开连接

发布于 2024-09-26 14:22:17 字数 324 浏览 0 评论 0原文

我有一个关于 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

焚却相思 2024-10-03 14:22:17

使用代理设计模式设法解决这个问题

Managed to solve this problem with the use of Proxy Design Pattern

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文