跨进程的Rx [英] Rx across processes

查看:80
本文介绍了跨进程的Rx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在进程B(processb.exe)中的IObserver使用进程A(processa.exe)中的IObservable?

Is it possible to have an IObservable in Process A (processa.exe) consumed by an IObserver in Process B (processb.exe) ?

推荐答案

您好,

是的,您可以使用.NET远程处理进行通信跨越流程边界。 使用Rx Experimental中的  远程
扩展程序,将您的observable转换为
的实例
MarshalByRefObject
。 进程A可以将observable作为属性的一部分返回到另一个
MarshalByRefObject ,您将手动创建并注册为众所周知的服务。 进程B可以通过.NET连接到
知名服务时自动生成的透明代理获取对该observable的引用。

Yes, you can use .NET remoting to communicate across process boundaries.  Use the Remotable extension from Rx Experimental to convert your observable into an instance of MarshalByRefObject.  Process A can return the observable as part of a property on another MarshalByRefObject, which you'll create manually and register as a well-known service.  Process B can then acquire a reference to that observable via the transparent proxy that .NET generates automatically when you connect to the well-known service.

但是,请注意, 远程的当前实现不提供指定生命周期服务的方法,因此使用.NET中的默认策略。 因此,除非您的申请在默认超时期限内持续传达
,否则您可能会发现您的观察结果有时会过早处理。  为了避免这种情况,您可以创建自己的
远程扩展并使用适当的终身服务(例如,在
InitializeLifetimeService
方法),或者您可以添加某种保持活动的服务,在应用程序不活动期间推送ping通知。

Note, however, that the current implementation of Remotable does not provide a way for you to specify a lifetime service, so the default policy in .NET is used.  Consequently, unless your application continuously communicates within the default timeout period, you may find that your observable is sometimes prematurely disposed.  To avoid this you can create your own Remotable extension and use an appropriate lifetime service (e.g., return null in the InitializeLifetimeService method), or you can add some kind of keep-alive service that pushes ping notifications during times of application inactivity.

- 戴夫


这篇关于跨进程的Rx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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