ISponsor Interface
Definição
Indica que o implementador deseja ser um responsável de concessão de tempo de vida.Indicates that the implementer wants to be a lifetime lease sponsor.
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
- Derivado
- Atributos
Exemplos
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;
}
[SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure)]
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
Comentários
Um objeto deve implementar a ISponsor interface se precisar solicitar uma renovação de concessão para um determinado objeto.An object must implement the ISponsor interface if it needs to request a lease renewal for a particular object. Um objeto que implementa a ISponsor interface pode se tornar um patrocinador, registrando-se com o Gerenciador de concessão.An object that implements the ISponsor interface can become a sponsor by registering itself with the lease manager. A ISponsor interface é usada pelo serviço de tempo de vida para chamar de volta para o patrocinador.The ISponsor interface is used by the lifetime service to call back to the sponsor.
Métodos
| Renewal(ILease) |
Solicitações de um cliente patrocinador para renovar a concessão para o objeto especificado.Requests a sponsoring client to renew the lease for the specified object. |