ISponsor 接口
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指示该实施者希望成为生存期租约主办方。
public interface class ISponsor
public interface ISponsor
[System.Runtime.InteropServices.ComVisible(true)]
public interface ISponsor
type ISponsor = interface
[<System.Runtime.InteropServices.ComVisible(true)>]
type ISponsor = interface
Public Interface ISponsor
- 派生
- 属性
示例
public ref class MyClientSponsor: public MarshalByRefObject, public ISponsor
{
private:
DateTime lastRenewal;
public:
MyClientSponsor()
{
lastRenewal = DateTime::Now;
}
[SecurityPermissionAttribute(SecurityAction::LinkDemand,Flags=SecurityPermissionFlag::Infrastructure)]
virtual TimeSpan Renewal( ILease^ /* lease */ )
{
Console::WriteLine( "Request to renew the lease time." );
Console::WriteLine( "Time since last renewal: {0}",
DateTime::Now - lastRenewal );
lastRenewal = DateTime::Now;
return TimeSpan::FromSeconds( 20 );
}
};
public class MyClientSponsor : MarshalByRefObject, ISponsor
{
private DateTime lastRenewal;
public MyClientSponsor()
{
lastRenewal = DateTime.Now;
}
public TimeSpan Renewal(ILease lease)
{
Console.WriteLine("Request to renew the lease time.");
Console.WriteLine("Time since last renewal: " +
(DateTime.Now - lastRenewal).ToString());
lastRenewal = DateTime.Now;
return TimeSpan.FromSeconds(20);
}
}
Public Class MyClientSponsor
Inherits MarshalByRefObject
Implements ISponsor
Private lastRenewal As DateTime
Public Sub New()
lastRenewal = DateTime.Now
End Sub
<SecurityPermission(SecurityAction.LinkDemand, Flags := SecurityPermissionFlag.Infrastructure)> _
Public Function Renewal(lease As ILease) As TimeSpan Implements ISponsor.Renewal
Console.WriteLine("Request to renew the lease time.")
Console.WriteLine("Time since last renewal: " + _
DateTime.op_Subtraction(DateTime.Now, lastRenewal).ToString())
lastRenewal = DateTime.Now
Return TimeSpan.FromSeconds(20)
End Function 'Renewal
End Class
注解
如果对象需要为特定对象请求租约续订,则它必须实现 ISponsor 接口。 实现 ISponsor 接口的对象可以通过向租约管理器注册自身来成为发起人。 ISponsor生存期服务使用该接口来回拨给发起人。
方法
Renewal(ILease) |
请求发起客户端续订指定对象的租约。 |