使用.Net Remoting的事件和代理 [英] using events and delegates with .Net Remoting

查看:85
本文介绍了使用.Net Remoting的事件和代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个与远程服务器(Windows服务)通信的winforms应用程序。所有数据库任务都将由服务器处理。我在网上看过几个例子。他们中的大多数在服务器端代码上使用委托和事件。我尝试不使用委托和事件,我直接调用服务器方法而不触发任何事件,它的工作原理。使用事件开发远程服务的目的是什么?

解决方案

我会提供一些关于这个主题的猜测,不过我不知道这是否是您找到的示例使用委托和事件的原因。
基本上,我可以想象一个开发人员可能希望实际上有命令和响应的场景在客户端和服务器之间。这将允许两者异步执行任务。

直接调用服务中的方法没有任何问题。我在几个项目上做同样的事情。这一切都取决于你正在进行的操作以及你可能期望从服务中获得响应的速度。

就像我说的那样纯粹的猜测,但这些都是我的想法......

I am developing a winforms application that will communicate with a remote server (windows service).  All database tasks will be processed by the server.  I have looked at several examples online.  Most of them use delegates and events on the server side code.  I tried not using delegates and events, I am calling the server methods directly without firing any event, and it works.  What is the purpose of using events for developing remote services?

解决方案

I'll offer some speculation on the subject, though I don't know if this is the reason the examples you found use delegates and events.

Basically, I could imagine a scenario in which a developer may want to, in effect, have a command and response between a client and server.  This would allow both to perform their tasks asynchronously.

There's nothing wrong with calling the methods in your service directly.  I do the same thing on several projects.  It all depends on the operation you're performing and the speed with which you might expect a response from the service.

Like I said, pure speculation, but those are my thoughts...


这篇关于使用.Net Remoting的事件和代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆