如何知道AppDomain租约是否已过期呢

在以下代码中

m_host = (RunAspxApp.Proxy.MyHost)ApplicationHost.CreateApplicationHost(typeof(RunAspxApp.Proxy.MyHost), "/",strDir);

如何知道m_host的租约是否已过期呢?

原来MarshalByRefObject有一个方法InitializeLifetimeService可以得到一个ILease对象,通过
try
{
ILease lease = (ILease)m_host.InitializeLifetimeService();
if(lease.CurrentState==LeaseState.Active)
return this.m_host;
}
catch{}//出错的话,就是过期了

哈哈哈,不知是不是一个笨方法。

posted @ 2006-06-14 17:18  生命体验之kevin-Y  阅读(388)  评论(0编辑  收藏  举报