LifetimeServices.RenewOnCallTime 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定每次呼叫來到伺服器物件時要據以延長使用期的時間數量。
public:
static property TimeSpan RenewOnCallTime { TimeSpan get(); void set(TimeSpan value); };
public static TimeSpan RenewOnCallTime { get; set; }
public static TimeSpan RenewOnCallTime { get; [System.Security.SecurityCritical] set; }
member this.RenewOnCallTime : TimeSpan with get, set
[<set: System.Security.SecurityCritical>]
member this.RenewOnCallTime : TimeSpan with get, set
Public Shared Property RenewOnCallTime As TimeSpan
屬性值
在每一個呼叫之後要據以延長目前 TimeSpan 中的存留期使用期的 AppDomain。
- 屬性
例外狀況
至少有一個呼叫堆疊中較高的呼叫端,不具有設定遠端類型和通道的使用權限。 只有在設定屬性值時才會擲回這個例外狀況。
範例
// Register the channel.
TcpChannel^ myChannel = gcnew TcpChannel;
ChannelServices::RegisterChannel( myChannel );
RemotingConfiguration::RegisterActivatedClientType( HelloService::typeid, "Tcp://localhost:8085" );
TimeSpan myTimeSpan = TimeSpan::FromMinutes( 10 );
// Create a remote object.
HelloService ^ myService = gcnew HelloService;
ILease^ myLease;
myLease = dynamic_cast<ILease^>(RemotingServices::GetLifetimeService( myService ));
if ( myLease == nullptr )
{
Console::WriteLine( "Cannot lease." );
return -1;
}
Console::WriteLine( "Initial lease time is {0}", myLease->InitialLeaseTime );
Console::WriteLine( "Current lease time is {0}", myLease->CurrentLeaseTime );
Console::WriteLine( "Renew on call time is {0}", myLease->RenewOnCallTime );
Console::WriteLine( "Sponsorship timeout is {0}", myLease->SponsorshipTimeout );
Console::WriteLine( "Current lease state is {0}", myLease->CurrentState );
// Register the channel.
TcpChannel myChannel = new TcpChannel ();
ChannelServices.RegisterChannel(myChannel);
RemotingConfiguration.RegisterActivatedClientType(
typeof(HelloService),"Tcp://localhost:8085");
TimeSpan myTimeSpan = TimeSpan.FromMinutes(10);
// Create a remote object.
HelloService myService = new HelloService();
ILease myLease;
myLease = (ILease)RemotingServices.GetLifetimeService(myService);
if (myLease == null)
{
Console.WriteLine("Cannot lease.");
return;
}
Console.WriteLine ("Initial lease time is " + myLease.InitialLeaseTime);
Console.WriteLine ("Current lease time is " + myLease.CurrentLeaseTime);
Console.WriteLine ("Renew on call time is " + myLease.RenewOnCallTime);
Console.WriteLine ("Sponsorship timeout is " + myLease.SponsorshipTimeout);
Console.WriteLine ("Current lease state is " + myLease.CurrentState.ToString());
' Register the channel.
Dim myChannel As New TcpChannel()
ChannelServices.RegisterChannel(myChannel)
RemotingConfiguration.RegisterActivatedClientType( _
GetType(HelloService), "Tcp://localhost:8085")
Dim myTimeSpan As TimeSpan = TimeSpan.FromMinutes(10)
' Create a remote object.
Dim myService As New HelloService()
Dim myLease As ILease
myLease = CType(RemotingServices.GetLifetimeService(myService), ILease)
If myLease Is Nothing Then
Console.WriteLine("Cannot lease.")
Return
End If
Console.WriteLine("Initial lease time is " & myLease.InitialLeaseTime.ToString())
Console.WriteLine("Current lease time is " & myLease.CurrentLeaseTime.ToString())
Console.WriteLine("Renew on call time is " & myLease.RenewOnCallTime.ToString())
Console.WriteLine("Sponsorship timeout is " & myLease.SponsorshipTimeout.ToString())
Console.WriteLine("Current lease state is " & myLease.CurrentState.ToString())
備註
延長存留期的預設更新時間是 2 分鐘。