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
- FunctionGenerator.cs
- LOSFormatter.cs
- CreatingCookieEventArgs.cs
- InitializationEventAttribute.cs
- AnnotationResourceChangedEventArgs.cs
- ZoneLinkButton.cs
- DispatcherSynchronizationContext.cs
- SoapHeaderAttribute.cs
- SweepDirectionValidation.cs
- CompilationRelaxations.cs
- ProgressBarRenderer.cs
- InkCanvasSelectionAdorner.cs
- QuadraticBezierSegment.cs
- StaticTextPointer.cs
- HierarchicalDataSourceControl.cs
- HttpModule.cs
- SvcMapFile.cs
- LicenseContext.cs
- Profiler.cs
- CodeEntryPointMethod.cs
- XmlKeywords.cs
- SQLInt64.cs
- SafeNativeMethods.cs
- TextTreeRootNode.cs
- ApplicationServiceHelper.cs
- Currency.cs
- ImageMap.cs
- EncodingStreamWrapper.cs
- URLIdentityPermission.cs
- PartManifestEntry.cs
- IdentityNotMappedException.cs
- HttpInputStream.cs
- SoapEnumAttribute.cs
- CheckBoxFlatAdapter.cs
- Thread.cs
- FontNamesConverter.cs
- StoreItemCollection.cs
- CustomError.cs
- DebuggerAttributes.cs
- SqlConnectionManager.cs
- ErrorFormatterPage.cs
- LocalizeDesigner.cs
- PathFigureCollectionConverter.cs
- OleDbReferenceCollection.cs
- CompressStream.cs
- SqlWebEventProvider.cs
- SocketInformation.cs
- AsymmetricKeyExchangeFormatter.cs
- FixedSOMTextRun.cs
- DataSourceHelper.cs
- XmlSchemaRedefine.cs
- MarshalByValueComponent.cs
- Invariant.cs
- WmfPlaceableFileHeader.cs
- XmlLinkedNode.cs
- Privilege.cs
- GradientStop.cs
- FormsAuthentication.cs
- Message.cs
- DataGridViewLinkCell.cs
- MimeImporter.cs
- GB18030Encoding.cs
- AuthenticationException.cs
- xml.cs
- CLRBindingWorker.cs
- SecurityDescriptor.cs
- InputScopeAttribute.cs
- XhtmlTextWriter.cs
- EventLog.cs
- TdsValueSetter.cs
- _SSPISessionCache.cs
- FocusManager.cs
- SupportedAddressingMode.cs
- ProcessModelInfo.cs
- SelectionRangeConverter.cs
- GrammarBuilderWildcard.cs
- ApplicationSecurityInfo.cs
- Msmq4PoisonHandler.cs
- ManifestResourceInfo.cs
- BamlBinaryReader.cs
- MetadataHelper.cs
- InvalidComObjectException.cs
- XamlPointCollectionSerializer.cs
- RelationshipEndCollection.cs
- BroadcastEventHelper.cs
- Compilation.cs
- HttpCookiesSection.cs
- ClickablePoint.cs
- MailAddress.cs
- RSAPKCS1SignatureDeformatter.cs
- SqlGenericUtil.cs
- OptimalBreakSession.cs
- DataGridTextBoxColumn.cs
- AssemblyResolver.cs
- SafeRightsManagementHandle.cs
- PropertyTab.cs
- VisualTreeHelper.cs
- BamlRecordReader.cs
- DesignConnection.cs
- RuntimeConfigurationRecord.cs