Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- COM2Enum.cs
- TextTreeTextBlock.cs
- httpserverutility.cs
- EventLogReader.cs
- DesignRelation.cs
- DataGridViewEditingControlShowingEventArgs.cs
- cookieexception.cs
- Queue.cs
- SHA512Managed.cs
- MembershipSection.cs
- GenericFlowSwitchHelper.cs
- ServiceManager.cs
- ImageField.cs
- Iis7Helper.cs
- ParserContext.cs
- RuleAttributes.cs
- SqlUserDefinedAggregateAttribute.cs
- TextRange.cs
- FolderBrowserDialog.cs
- AlphabeticalEnumConverter.cs
- TextSpan.cs
- CompoundFileReference.cs
- DataObjectSettingDataEventArgs.cs
- OrderToken.cs
- IImplicitResourceProvider.cs
- AspProxy.cs
- EntitySetDataBindingList.cs
- SyndicationElementExtension.cs
- FlowPosition.cs
- GeneralTransform3DTo2D.cs
- ActiveXMessageFormatter.cs
- XmlSchemaAnnotation.cs
- ForeignKeyConstraint.cs
- cookie.cs
- SecurityPermission.cs
- Color.cs
- RelationshipType.cs
- PropertyEmitter.cs
- FieldBuilder.cs
- CreatingCookieEventArgs.cs
- DefaultHttpHandler.cs
- XmlQueryCardinality.cs
- QueueTransferProtocol.cs
- AuthenticatedStream.cs
- OleDbDataReader.cs
- WindowsBrush.cs
- OperatingSystem.cs
- ResetableIterator.cs
- SHA1.cs
- DataViewListener.cs
- RichTextBox.cs
- SvcMapFile.cs
- COAUTHIDENTITY.cs
- VerificationAttribute.cs
- UrlMapping.cs
- SqlTriggerAttribute.cs
- SqlCommand.cs
- SmiMetaDataProperty.cs
- IndexOutOfRangeException.cs
- Effect.cs
- SecurityUtils.cs
- MobilePage.cs
- SecurityPolicySection.cs
- SerializationInfoEnumerator.cs
- AnnouncementEventArgs.cs
- IndexOutOfRangeException.cs
- CustomValidator.cs
- FreezableOperations.cs
- precedingquery.cs
- EditorPartCollection.cs
- EventDescriptorCollection.cs
- StringDictionary.cs
- cryptoapiTransform.cs
- ToolStripGrip.cs
- KeyTime.cs
- CodeCatchClause.cs
- CompiledXpathExpr.cs
- TextViewBase.cs
- Graphics.cs
- PenCursorManager.cs
- UInt16.cs
- DotNetATv1WindowsLogEntryDeserializer.cs
- OpacityConverter.cs
- CommandCollectionEditor.cs
- BitmapSizeOptions.cs
- ToolStripItemClickedEventArgs.cs
- MetricEntry.cs
- _emptywebproxy.cs
- Mapping.cs
- _SpnDictionary.cs
- X509Chain.cs
- DecoderBestFitFallback.cs
- EventDescriptor.cs
- ObjectDataSourceEventArgs.cs
- MatrixKeyFrameCollection.cs
- ConfigXmlSignificantWhitespace.cs
- StorageMappingItemCollection.cs
- DbMetaDataCollectionNames.cs
- QueryExpr.cs
- WhereaboutsReader.cs