当前位置: 首页>>代码示例>>C#>>正文


C# MarshalByRefObject.GetLifetimeService方法代码示例

本文整理汇总了C#中System.MarshalByRefObject.GetLifetimeService方法的典型用法代码示例。如果您正苦于以下问题:C# MarshalByRefObject.GetLifetimeService方法的具体用法?C# MarshalByRefObject.GetLifetimeService怎么用?C# MarshalByRefObject.GetLifetimeService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.MarshalByRefObject的用法示例。


在下文中一共展示了MarshalByRefObject.GetLifetimeService方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Register

        [System.Security.SecurityCritical]  // auto-generated
        public bool Register(MarshalByRefObject obj) 
        {
            BCLDebug.Trace("REMOTE", "ClientSponsor Register "+obj);
            ILease lease = (ILease)obj.GetLifetimeService();
            if (lease == null) 
                return false;
 
            lease.Register(this); 
            lock(sponsorTable)
            { 
                sponsorTable[obj] = lease;
            }
            return true;
        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:15,代码来源:ClientSponsor.cs

示例2: Register

 public bool Register(MarshalByRefObject obj)
 {
     ILease lifetimeService = (ILease) obj.GetLifetimeService();
     if (lifetimeService == null)
     {
         return false;
     }
     lifetimeService.Register(this);
     lock (this.sponsorTable)
     {
         this.sponsorTable[obj] = lifetimeService;
     }
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:14,代码来源:ClientSponsor.cs

示例3: Register

 public void Register(MarshalByRefObject obj)
 {
     Func<KeyValuePair<ILease, WeakReference>, bool> predicate = null;
     if (obj == null)
     {
         throw new ArgumentNullException();
     }
     ILease Lease = (ILease) obj.GetLifetimeService();
     lock (this.LeaseObjectList)
     {
         if (predicate == null)
         {
             predicate = delegate (KeyValuePair<ILease, WeakReference> x) {
                 return object.ReferenceEquals(x, Lease);
             };
         }
         if (!this.LeaseObjectList.Any<KeyValuePair<ILease, WeakReference>>(predicate))
         {
             this.LeaseObjectList.AddFirst(new KeyValuePair<ILease, WeakReference>(Lease, new WeakReference(obj)));
             Lease.Register(this);
         }
     }
 }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:23,代码来源:WeakClientSponsor.cs

示例4: MarshalInternal


//.........这里部分代码省略.........
 
            // Retime lease on every marshal on the server side
            // and extend lease on every marshal on the client side <EMAIL>- GopalK</EMAIL>
            ServerIdentity srvId = idObj as ServerIdentity;
            if (srvId != null) 
            {
                // Ensure that the lease is started soon as the object is 
                // marshaled. 
                MarshalByRefObject obj = null;
                // This call forces creation of the lifetime lease sink. 
                srvId.GetServerObjectChain(out obj);

                // Server side ... object being marshaled => give it another
                // full lease 
                Lease lease = idObj.Lease;
                if (lease != null) 
                { 
                    // We always make Identity reference our own Lease though
                    // the actual object implements its own ILease object. 
                    // This seems completely broken. Further, ILease interface
                    // should have the activate method.  <EMAIL>- GopalK</EMAIL>

                    // This lock ensures coordination with the lifetime service 
                    // which might have decided to Disconnect the object about
                    // the same time as it is being marshaled 
                    lock (lease) 
                    {
                        if (lease.CurrentState == LeaseState.Expired) 
                        {
                            // Lease.Renew is a no-op if LeaseState==Expired
                            // So we do a full ActivateLease
                            lease.ActivateLease(); 
                        }
                        else 
                        { 
                            // Lease is still around. Just increase the time
                            lease.RenewInternal(idObj.Lease.InitialLeaseTime); 
                        }
                    }
                }
 
                // Every marshal should also ensure that the channel data
                // being carried in the objRef reflects the latest data from 
                // regisetered channels 
                // <
                if (updateChannelData && objectRef.ChannelInfo != null) 
                {
                    // Create the channel info
                    Object[] channelData = ChannelServices.CurrentChannelData;
                    // Make sure the channelInfo only has x-appdomain data since the objref is agile while other 
                    // channelData might not be and regardless this data is useless for an appdomain proxy
                    if (!(Obj is AppDomain)) 
                        objectRef.ChannelInfo.ChannelData = channelData; 
                    else
                    { 
                        int channelDataLength = channelData.Length;
                        Object[] newChannelData = new Object[channelDataLength];
                        // Clone the data so that we dont [....] the current appdomain data which is stored
                        // as a static 
                        Array.Copy(channelData, newChannelData, channelDataLength);
                        for (int i = 0; i < channelDataLength; i++) 
                        { 
                            if (!(newChannelData[i] is CrossAppDomainData))
                                newChannelData[i] = null; 
                        }
                        objectRef.ChannelInfo.ChannelData = newChannelData;
                    }
                } 
            }
            else 
            { 
#if false
                /* 



*/ 
                ILease lease = idObj.Lease;
                if (lease == null) 
                { 
                    lease = (ILease)Obj.GetLifetimeService();
                } 
                if (lease != null)
                {
                    lease.Renew(lease.RenewOnCallTime);
                } 
#endif
            } 
 
            // Notify TrackingServices that an object has been marshaled
            // NOTE: This call also keeps the object alive otherwise GC 
            // can report it as dead anytime inside this call when it thinks
            // that the object will no longer be referenced, either inside
            // this call or outside.
            /* < 
*/
 
            TrackingServices.MarshaledObject(Obj, objectRef); 
            return objectRef;
        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:101,代码来源:RemotingServices.cs

示例5: GetLifetimeService

 [System.Security.SecuritySafeCritical]  // auto-generated 
 public static Object GetLifetimeService(MarshalByRefObject obj)
 { 
     if(null != obj)
     {
         return obj.GetLifetimeService();
     } 
     else
     { 
         return null; 
     }
 } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:12,代码来源:RemotingServices.cs

示例6: Unregister

		public void Unregister (MarshalByRefObject obj)
		{
			if (!registered_objects.ContainsKey (obj)) return;
			ILease lease = obj.GetLifetimeService () as ILease;
			lease.Unregister (this);
			registered_objects.Remove (obj);
		}
开发者ID:jack-pappas,项目名称:mono,代码行数:7,代码来源:ClientSponsor.cs

示例7: Register

		public bool Register (MarshalByRefObject obj)
		{
			if (registered_objects.ContainsKey (obj)) return false;
			ILease lease = obj.GetLifetimeService () as ILease;
			if (lease == null) return false;
			lease.Register (this);
			registered_objects.Add (obj,obj);
			return true;
		}
开发者ID:jack-pappas,项目名称:mono,代码行数:9,代码来源:ClientSponsor.cs

示例8: GetLifetimeService

 public static object GetLifetimeService(MarshalByRefObject obj)
 {
     if (obj != null)
     {
         return obj.GetLifetimeService();
     }
     return null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:RemotingServices.cs

示例9: RegisterLifetimeService

 internal void RegisterLifetimeService(MarshalByRefObject obj)
 {
     ILease lease = (ILease)obj.GetLifetimeService();
     if (lease != null)
         lease.Register(RemotingClientSponsor);
 }
开发者ID:hpavlov,项目名称:occurec,代码行数:6,代码来源:ASCOMClient.cs

示例10: Unregister

 public bool Unregister(MarshalByRefObject obj)
 {
     Predicate<KeyValuePair<ILease, WeakReference>> match = null;
     if (obj == null)
     {
         throw new ArgumentNullException();
     }
     ILease Lease = (ILease) obj.GetLifetimeService();
     lock (this.LeaseObjectList)
     {
         if (match == null)
         {
             match = delegate (KeyValuePair<ILease, WeakReference> x) {
                 return object.ReferenceEquals(x, Lease);
             };
         }
         if (this.LeaseObjectList.RemoveAll(match) > 0)
         {
             Lease.Unregister(this);
             return true;
         }
     }
     return false;
 }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:24,代码来源:WeakClientSponsor.cs


注:本文中的System.MarshalByRefObject.GetLifetimeService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。