本文介绍了ISponsor和ILease接口如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个继承自 MarshalByRefObject ISponsor 的对象。在我的 ISponsor 的实现中,我只是返回一个时间跨度以指示我希望将该对象续订多长时间。

I've created a object that inherits from MarshalByRefObject and ISponsor. In my implementation of ISponsor I just return a timespan to indicate how long I want the object renewed for.

何时我致电 InitializeLifetimeService()以获得 ILease 引用,该引用将传递到我的 ISponsor 对象,它似乎永远不会被使用。

When I call InitializeLifetimeService() to get an ILease reference to be passed into my ISponsor object it never appears to be used from examples I've seen.

ISponsor 似乎只是返回一个TimeSpan而不实际使用 ILase 参考。但是我敢肯定,由于涉及到远程处理,因此还有更多事情要做。

ISponsor just seems to return a TimeSpan without actually using the ILease reference. But I'm sure there is more going on here since remoting is involved.

ISponsor ILease 是否起作用,特别是在对象生命周期更新方面?

How do ISponsor and ILease work, specifically in terms of object lifetime renewal?

推荐答案

在父级AppDomain中您可以通过 InitializeLifetimeService GetLifetimeService 调用,并使用新AppDomain中的对象的代理实例来获取ILease对象。您无需自己实现 ILease (在测试 ISponsor 实现之外)。

In parent AppDomain you obtain ILease object by either InitializeLifetimeService or GetLifetimeService call with proxy instance of object in the new AppDomain. You never need to implement ILease yourself (outside of testing your ISponsor implementation).

比起您注册自定义的发起人对象,该对象通过 ILease实现 ISponsor 。注册调用并配置 ILease 对象超时。

Than you register your custom Sponsor object which implements ISponsor with ILease.Register call and configure ILease object with timeouts.

当您的Sponsor对象通过 Renewal 致电时,您可以说保持对象多长时间并可以调整/ display在 ILease 实例中传递的属性。

When your Sponsor object get called with Renewal you can say how long to keep the object alive and also may adjust/display properties of passed in ILease instance.

这篇关于ISponsor和ILease接口如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 23:56