Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / clr / src / BCL / System / Runtime / Remoting / ClientSponsor.cs / 1 / ClientSponsor.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== //+---------------------------------------------------------------------------- // // File: ClientSponsor.cs // // Contents: Agent for keeping Server Object's lifetime in [....] with a client's lifetime // // History: 8/9/00[....] Created // //+--------------------------------------------------------------------------- namespace System.Runtime.Remoting.Lifetime { using System; using System.Collections; using System.Security.Permissions; [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure)] [SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags=SecurityPermissionFlag.Infrastructure)] [System.Runtime.InteropServices.ComVisible(true)] public class ClientSponsor : MarshalByRefObject, ISponsor { private Hashtable sponsorTable = new Hashtable(10); private TimeSpan m_renewalTime = TimeSpan.FromMinutes(2); public ClientSponsor() { } public ClientSponsor(TimeSpan renewalTime) { this.m_renewalTime = renewalTime; } public TimeSpan RenewalTime { get{ return m_renewalTime;} set{ m_renewalTime = value;} } 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; } public void Unregister(MarshalByRefObject obj) { BCLDebug.Trace("REMOTE", "ClientSponsor Unregister "+obj); ILease lease = null; lock(sponsorTable) { lease = (ILease)sponsorTable[obj]; } if (lease != null) lease.Unregister(this); } // ISponsor method public TimeSpan Renewal(ILease lease) { BCLDebug.Trace("REMOTE", "ClientSponsor Renewal "+m_renewalTime); return m_renewalTime; } public void Close() { BCLDebug.Trace("REMOTE","ClientSponsor Close"); lock(sponsorTable) { IDictionaryEnumerator e = sponsorTable.GetEnumerator(); while(e.MoveNext()) ((ILease)e.Value).Unregister(this); sponsorTable.Clear(); } } // Don't create a lease on the sponsor public override Object InitializeLifetimeService() { return null; } ~ClientSponsor() { BCLDebug.Trace("REMOTE","ClientSponsor Finalize"); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== //+---------------------------------------------------------------------------- // // File: ClientSponsor.cs // // Contents: Agent for keeping Server Object's lifetime in [....] with a client's lifetime // // History: 8/9/00[....] Created // //+--------------------------------------------------------------------------- namespace System.Runtime.Remoting.Lifetime { using System; using System.Collections; using System.Security.Permissions; [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure)] [SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags=SecurityPermissionFlag.Infrastructure)] [System.Runtime.InteropServices.ComVisible(true)] public class ClientSponsor : MarshalByRefObject, ISponsor { private Hashtable sponsorTable = new Hashtable(10); private TimeSpan m_renewalTime = TimeSpan.FromMinutes(2); public ClientSponsor() { } public ClientSponsor(TimeSpan renewalTime) { this.m_renewalTime = renewalTime; } public TimeSpan RenewalTime { get{ return m_renewalTime;} set{ m_renewalTime = value;} } 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; } public void Unregister(MarshalByRefObject obj) { BCLDebug.Trace("REMOTE", "ClientSponsor Unregister "+obj); ILease lease = null; lock(sponsorTable) { lease = (ILease)sponsorTable[obj]; } if (lease != null) lease.Unregister(this); } // ISponsor method public TimeSpan Renewal(ILease lease) { BCLDebug.Trace("REMOTE", "ClientSponsor Renewal "+m_renewalTime); return m_renewalTime; } public void Close() { BCLDebug.Trace("REMOTE","ClientSponsor Close"); lock(sponsorTable) { IDictionaryEnumerator e = sponsorTable.GetEnumerator(); while(e.MoveNext()) ((ILease)e.Value).Unregister(this); sponsorTable.Clear(); } } // Don't create a lease on the sponsor public override Object InitializeLifetimeService() { return null; } ~ClientSponsor() { BCLDebug.Trace("REMOTE","ClientSponsor Finalize"); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BamlLocalizableResourceKey.cs
- LockCookie.cs
- DataGridViewLinkColumn.cs
- BinHexEncoder.cs
- SubMenuStyleCollection.cs
- TextServicesProperty.cs
- ISAPIApplicationHost.cs
- WebScriptEndpoint.cs
- GridEntry.cs
- ConfigurationException.cs
- VoiceInfo.cs
- DecoderExceptionFallback.cs
- XamlPathDataSerializer.cs
- MsmqIntegrationProcessProtocolHandler.cs
- HttpCookieCollection.cs
- MessageQueuePermissionEntryCollection.cs
- WebPartVerb.cs
- EditorPartChrome.cs
- Point3DConverter.cs
- SignatureToken.cs
- TextServicesDisplayAttributePropertyRanges.cs
- FunctionNode.cs
- JsonServiceDocumentSerializer.cs
- ConvertEvent.cs
- WebPartTransformerCollection.cs
- IProducerConsumerCollection.cs
- ProtocolElement.cs
- UnionCqlBlock.cs
- DataSourceXmlClassAttribute.cs
- MetadataPropertyAttribute.cs
- NavigationPropertyEmitter.cs
- ShapingWorkspace.cs
- TextDecorationLocationValidation.cs
- InheritanceAttribute.cs
- IndicShape.cs
- ImageCollectionCodeDomSerializer.cs
- TemplateParser.cs
- DataGridItemCollection.cs
- PerspectiveCamera.cs
- MulticastDelegate.cs
- EncryptedKey.cs
- CompilerGeneratedAttribute.cs
- CachingHintValidation.cs
- LinearKeyFrames.cs
- BaseParaClient.cs
- StringSource.cs
- ListParagraph.cs
- FtpWebRequest.cs
- AdornerLayer.cs
- SessionIDManager.cs
- ConfigXmlCDataSection.cs
- RSACryptoServiceProvider.cs
- KnownTypesHelper.cs
- SafeNativeMethodsOther.cs
- SymmetricAlgorithm.cs
- UIElementIsland.cs
- _DynamicWinsockMethods.cs
- QuestionEventArgs.cs
- PermissionSetTriple.cs
- ProcessRequestArgs.cs
- Helpers.cs
- ConnectionStringSettingsCollection.cs
- InvariantComparer.cs
- ErrorWebPart.cs
- DecimalMinMaxAggregationOperator.cs
- XmlLoader.cs
- Win32MouseDevice.cs
- XmlDocument.cs
- Crypto.cs
- InitiatorSessionSymmetricTransportSecurityProtocol.cs
- BamlLocalizableResource.cs
- ClientRequest.cs
- SqlInternalConnectionTds.cs
- DragDeltaEventArgs.cs
- TagPrefixAttribute.cs
- SortQuery.cs
- CircleHotSpot.cs
- XmlSchemaAttributeGroupRef.cs
- DesignerDataSchemaClass.cs
- RelationshipConverter.cs
- WebPartConnectionsCancelVerb.cs
- TextAutomationPeer.cs
- PrimitiveSchema.cs
- LineVisual.cs
- CommonXSendMessage.cs
- EditorAttribute.cs
- LicFileLicenseProvider.cs
- GiveFeedbackEvent.cs
- ProfileSettings.cs
- OutputScope.cs
- InputLanguageCollection.cs
- SelectionWordBreaker.cs
- CodeSnippetExpression.cs
- GPRECT.cs
- EventMappingSettingsCollection.cs
- ViewStateModeByIdAttribute.cs
- MasterPage.cs
- PropertyPanel.cs
- TimeEnumHelper.cs
- ValidatorCompatibilityHelper.cs