ClientSponsor Class
Provides a default implementation for a lifetime sponsor class.
Assembly: mscorlib (in mscorlib.dll)
| Name | Description | |
|---|---|---|
![]() | ClientSponsor() | Initializes a new instance of the ClientSponsor class with default values. |
![]() | ClientSponsor(TimeSpan) | Initializes a new instance of the ClientSponsor class with the renewal time of the sponsored object. |
| Name | Description | |
|---|---|---|
![]() | RenewalTime | Gets or sets the TimeSpan by which to increase the lifetime of the sponsored objects when renewal is requested. |
| Name | Description | |
|---|---|---|
![]() | Close() | Empties the list objects registered with the current ClientSponsor. |
![]() | CreateObjRef(Type) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.(Inherited from MarshalByRefObject.) |
![]() | Equals(Object) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | Finalize() | Frees the resources of the current ClientSponsor before the garbage collector reclaims them.(Overrides Object.Finalize().) |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetLifetimeService() | Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.) |
![]() | GetType() | |
![]() | InitializeLifetimeService() | Initializes a new instance of ClientSponsor, providing a lease for the current object.(Overrides MarshalByRefObject.InitializeLifetimeService().) |
![]() | MemberwiseClone() | |
![]() | MemberwiseClone(Boolean) | Creates a shallow copy of the current MarshalByRefObject object.(Inherited from MarshalByRefObject.) |
![]() | Register(MarshalByRefObject) | Registers the specified MarshalByRefObject for sponsorship. |
![]() | Renewal(ILease) | Requests a sponsoring client to renew the lease for the specified object. |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
![]() | Unregister(MarshalByRefObject) | Unregisters the specified MarshalByRefObject from the list of objects sponsored by the current ClientSponsor. |
The current lifetime sponsor implementation can be used to sponsor objects by specifying the required renewal TimeSpan.
Note |
|---|
This class makes a link demand and an inheritance demand at the class level. A SecurityException is thrown when either the immediate caller or the derived class does not have infrastructure permission. For details about security demands, see Link Demands and Inheritance Demands. |
The following example illustrates the ClientSponsor class to extend the life of a class-activated remote object.
Imports System Imports System.Runtime.Remoting Imports System.Runtime.Remoting.Channels Imports System.Runtime.Remoting.Channels.Tcp Imports System.Runtime.Remoting.Lifetime Namespace RemotingSamples 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 End Namespace 'RemotingSamples
for operating with infrastructure code. Demand value: SecurityAction.LinkDemand; Permission Value: SecurityPermissionFlag.Infrastructure
for operating with infrastructure code. Demand value: SecurityAction.InheritanceDemand; Permission Value: SecurityPermissionFlag.Infrastructure
Available since 1.1
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.



