ClientSponsor.InitializeLifetimeService メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ClientSponsor.InitializeLifetimeService メソッドの意味・解説 

ClientSponsor.InitializeLifetimeService メソッド

現在のオブジェクトリース使用して、ClientSponsor の新しインスタンス初期化します。

名前空間: System.Runtime.Remoting.Lifetime
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Overrides Function
 InitializeLifetimeService As Object
Dim instance As ClientSponsor
Dim returnValue As Object

returnValue = instance.InitializeLifetimeService
public override Object InitializeLifetimeService ()
public:
virtual Object^ InitializeLifetimeService () override
public Object InitializeLifetimeService ()
public override function InitializeLifetimeService
 () : Object

戻り値
現在のオブジェクトの ILease。

解説解説

詳細については、「MarshalByRefObject.InitializeLifetimeService」を参照してください

使用例使用例
Class HelloClient

   Shared Sub Main()
      ' Register a channel.
      Dim myChannel As New
 TcpChannel()
      ChannelServices.RegisterChannel(myChannel)
      RemotingConfiguration.RegisterActivatedClientType( _
                  GetType(HelloService), "tcp://localhost:8085")

      ' Get the remote object.
      Dim myService As New
 HelloService()

      ' Get a sponsor for renewal of time.
      Dim mySponsor As New
 ClientSponsor()

      ' Register the service with sponsor.
      mySponsor.Register(myService)

      ' Set renewaltime.
      mySponsor.RenewalTime = TimeSpan.FromMinutes(2)

      ' Renew the lease.
      Dim myLease As ILease = CType(mySponsor.InitializeLifetimeService(),
 ILease)
      Dim myTime As TimeSpan = mySponsor.Renewal(myLease)
      Console.WriteLine("Renewed time in minutes is "
 & myTime.Minutes)

      ' Call the remote method.
      Console.WriteLine(myService.HelloMethod("World"))

      ' Unregister the channel.
      mySponsor.Unregister(myService)
      mySponsor.Close()
   End Sub 'Main
End Class 'HelloClient
class HelloClient
{
    static void Main()
   {
      // Register a channel.
      TcpChannel myChannel = new TcpChannel ();
      ChannelServices.RegisterChannel(myChannel);
      RemotingConfiguration.RegisterActivatedClientType(
                             typeof(HelloService),"tcp://localhost:8085/");

      // Get the remote object.
      HelloService myService = new HelloService();

      // Get a sponsor for renewal of time.
      ClientSponsor mySponsor = new ClientSponsor();

      // Register the service with sponsor.
      mySponsor.Register(myService);

      // Set renewaltime.
      mySponsor.RenewalTime = TimeSpan.FromMinutes(2);

      // Renew the lease.
      ILease myLease = (ILease)mySponsor.InitializeLifetimeService();
      TimeSpan myTime = mySponsor.Renewal(myLease);
      Console.WriteLine("Renewed time in minutes is "
 + myTime.Minutes.ToString());

      // Call the remote method.
      Console.WriteLine(myService.HelloMethod("World"));

      // Unregister the channel.
      mySponsor.Unregister(myService);
      mySponsor.Close();
   }
}
int main()
{
   // Register a channel.
   TcpChannel^ myChannel = gcnew TcpChannel;
   ChannelServices::RegisterChannel( myChannel );
   RemotingConfiguration::RegisterActivatedClientType(
      RemotingSamples::HelloService::typeid, "tcp://localhost:8085/"
 );
   
   // Get the remote Object*.
   RemotingSamples::HelloService ^ myService = gcnew RemotingSamples::HelloService;
   
   // Get a sponsor for renewal of time.
   ClientSponsor^ mySponsor = gcnew ClientSponsor;
   
   // Register the service with sponsor.
   mySponsor->Register( myService );
   
   // Set renewaltime.
   mySponsor->RenewalTime = TimeSpan::FromMinutes( 2 );
   
   // Renew the lease.
   ILease^ myLease = dynamic_cast<ILease^>(mySponsor->InitializeLifetimeService());
   TimeSpan myTime = mySponsor->Renewal( myLease );
   Console::WriteLine( "Renewed time in minutes is {0}",
 myTime.Minutes );
   
   // Call the remote method.
   Console::WriteLine( myService->HelloMethod( "World" ) );
   
   // Unregister the channel.
   mySponsor->Unregister( myService );
   mySponsor->Close();
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ClientSponsor クラス
ClientSponsor メンバ
System.Runtime.Remoting.Lifetime 名前空間
InitializeLifetimeService



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

ClientSponsor.InitializeLifetimeService メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ClientSponsor.InitializeLifetimeService メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS