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
- HtmlTernaryTree.cs
- SkinBuilder.cs
- ConfigurationElementCollection.cs
- SqlNodeAnnotation.cs
- ClientFactory.cs
- NameValuePair.cs
- XPathArrayIterator.cs
- COMException.cs
- PrimitiveXmlSerializers.cs
- X509Chain.cs
- MessageSecurityOverTcpElement.cs
- ProfileGroupSettingsCollection.cs
- NotImplementedException.cs
- CellQuery.cs
- ConnectionStringsExpressionBuilder.cs
- ContentValidator.cs
- IndexOutOfRangeException.cs
- ObjectQuery_EntitySqlExtensions.cs
- AssertUtility.cs
- XmlDocumentFragment.cs
- mongolianshape.cs
- TransformGroup.cs
- ColumnWidthChangingEvent.cs
- Certificate.cs
- DataTable.cs
- StorageModelBuildProvider.cs
- CFGGrammar.cs
- XmlDeclaration.cs
- IdentifierCollection.cs
- KerberosTokenFactoryCredential.cs
- Hex.cs
- UrlMapping.cs
- Unit.cs
- documentsequencetextcontainer.cs
- WebHeaderCollection.cs
- WebPartMinimizeVerb.cs
- PermissionSet.cs
- ProcessThreadCollection.cs
- ReadOnlyCollectionBase.cs
- DispatchWrapper.cs
- DataTableCollection.cs
- StructuralCache.cs
- DataGridViewTextBoxEditingControl.cs
- StrokeSerializer.cs
- panel.cs
- SelectorItemAutomationPeer.cs
- ScrollChrome.cs
- ListBindableAttribute.cs
- StreamWriter.cs
- TreeNodeConverter.cs
- ControlTemplate.cs
- InternalException.cs
- TemplateControlParser.cs
- ServiceHandle.cs
- DesignerActionGlyph.cs
- TextFindEngine.cs
- MessageHeaderDescriptionCollection.cs
- DocumentPageHost.cs
- TextContainerChangeEventArgs.cs
- XmlMessageFormatter.cs
- WindowsStartMenu.cs
- TableHeaderCell.cs
- XPathDocumentBuilder.cs
- SHA256Managed.cs
- Compiler.cs
- FlowDocumentScrollViewer.cs
- UserControlAutomationPeer.cs
- DataFormats.cs
- MenuItemCollection.cs
- CodeExpressionStatement.cs
- Package.cs
- StreamingContext.cs
- URI.cs
- WmlLinkAdapter.cs
- SchemaCollectionPreprocessor.cs
- DataBindingCollectionConverter.cs
- XPathQilFactory.cs
- FormsAuthenticationModule.cs
- OptimalTextSource.cs
- StrokeNode.cs
- DataGridGeneralPage.cs
- XPathNavigatorReader.cs
- PerfCounterSection.cs
- MailDefinition.cs
- ConstructorNeedsTagAttribute.cs
- XslAstAnalyzer.cs
- TemplateBindingExpression.cs
- DropTarget.cs
- Root.cs
- ConnectionPointGlyph.cs
- DbgCompiler.cs
- AmbiguousMatchException.cs
- PartitionResolver.cs
- MembershipSection.cs
- EndEvent.cs
- IUnknownConstantAttribute.cs
- LinearQuaternionKeyFrame.cs
- ContextStack.cs
- MimeTypePropertyAttribute.cs
- BaseParagraph.cs