当对象变量通过 ByRef 发送到服务进行处理时,如何对其进行管理?
服务器位于位置 A
我托管了一个服务,它将处理收到的数组(ByRef)。
位于位置 B 的客户端计算机
我在应用程序中有一个方法,它将从用户处获取字符串,将其添加到数组对象并调用 ServiceMethod 来处理数组(通过 ByRef 传递),然后我会告诉你 结果显示在屏幕上。
我的理解
当任何事物通过引用传递时,内存位置都会被传递,因此对“事物”采取的任何操作都会在“事物”的位置上采取。
问题
对于“东西”来说,位于同一台电脑/内存上是可以的。但是
当“东西”位于另一台电脑上时会发生什么?接收者做什么?它是否一点一点地访问远在千里之外的发送者的内存?
Server at location A
I have a Service hosted which will process array received(ByRef) .
Client Computer at Location B
I have a method in the application which will take strings from the user, add it to the array object and call the ServiceMethod to have the Array processed(which is passed ByRef), then i will show you the
result on screen.
What i Understand
When any thing is passed by reference, the memory location is passed therefore any action taken on the "thing" is taken on the location of the "thing".
Question
For the "thing" to be on the same PC/Memory its okay. but
What happens when the "thing" is on a different PC? What does the Receiver do? Does it access the memory bit by bit of the sender which is thousands of miles away?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这实际上取决于非常精确的场景。 常规 WCF 通常会将
ref
解释为“将此数据序列化到服务,让服务使用它,然后将数据序列化回客户端” - 因此 <ref
的 em>语义 是相似的,但实现却非常不同。在使用过程中,服务器仅与数据的本地副本通信,因此不存在巨大的性能问题 - 但是,如果您发送一个巨大的byte[]
,然后仅从中访问 2 个字节,仍然必须将所有数据发送两次(双向)。It really depends on the very precise scenario. Regular WCF will generally interpret
ref
as a "serialize this data to the service, let the service play with it, then serialize the data back to the client" - so the semantic ofref
is then similar, but the implementation is very different. During usage, the server is only talking to the local copy of the data, so there is no huge performance issue - however, if you send a hugebyte[]
and then only access 2 bytes from it, is still has to send all that data twice (both directions).