當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。