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
- TextReader.cs
- HierarchicalDataSourceControl.cs
- WSSecurityOneDotOneReceiveSecurityHeader.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- StackSpiller.Generated.cs
- TypeElementCollection.cs
- XmlSchemaImporter.cs
- DesignerTransactionCloseEvent.cs
- GatewayIPAddressInformationCollection.cs
- SqlLiftWhereClauses.cs
- TransformGroup.cs
- DataGridViewHeaderCell.cs
- GridLength.cs
- XmlQueryType.cs
- UnionCodeGroup.cs
- AppearanceEditorPart.cs
- EntityWrapperFactory.cs
- ProtocolReflector.cs
- DiscoveryReferences.cs
- Thickness.cs
- ExtensibleClassFactory.cs
- StringReader.cs
- PageThemeBuildProvider.cs
- EdmProviderManifest.cs
- ChildTable.cs
- OracleMonthSpan.cs
- _ListenerRequestStream.cs
- WorkflowOwnershipException.cs
- InternalSafeNativeMethods.cs
- IImplicitResourceProvider.cs
- XmlDataSourceView.cs
- HwndSourceParameters.cs
- HttpHandlerAction.cs
- TextServicesProperty.cs
- Transform3DGroup.cs
- ButtonBaseAutomationPeer.cs
- RoleGroupCollection.cs
- GridLengthConverter.cs
- LeaseManager.cs
- Baml2006ReaderFrame.cs
- WorkflowViewStateService.cs
- SkipQueryOptionExpression.cs
- ServiceEndpointElementCollection.cs
- DeviceOverridableAttribute.cs
- FontWeightConverter.cs
- ValueUnavailableException.cs
- TimeSpanConverter.cs
- Transactions.cs
- NetworkInterface.cs
- PropertyFilterAttribute.cs
- ThreadAbortException.cs
- PropertyPath.cs
- DurationConverter.cs
- AppDomainFactory.cs
- ModuleConfigurationInfo.cs
- FixedStringLookup.cs
- SettingsBase.cs
- IsolatedStoragePermission.cs
- ObjectNavigationPropertyMapping.cs
- TextEffectResolver.cs
- OdbcParameterCollection.cs
- CodeStatementCollection.cs
- RIPEMD160Managed.cs
- ImmutablePropertyDescriptorGridEntry.cs
- ScriptComponentDescriptor.cs
- TreeNodeEventArgs.cs
- EditorPartChrome.cs
- CombinedTcpChannel.cs
- DataObject.cs
- Size3D.cs
- TemplateControlCodeDomTreeGenerator.cs
- Int64AnimationUsingKeyFrames.cs
- DrawingCollection.cs
- FlowDocument.cs
- GridViewDeletedEventArgs.cs
- SqlError.cs
- WorkflowViewElement.cs
- ThemeableAttribute.cs
- NodeFunctions.cs
- CodeIterationStatement.cs
- SerializationTrace.cs
- TextSegment.cs
- ExtenderControl.cs
- RequestResponse.cs
- Page.cs
- CodeAssignStatement.cs
- StringConcat.cs
- StateWorkerRequest.cs
- RegexWorker.cs
- SystemUdpStatistics.cs
- ChangeInterceptorAttribute.cs
- PreservationFileReader.cs
- LocalizationParserHooks.cs
- SqlParameterCollection.cs
- LingerOption.cs
- AsyncPostBackErrorEventArgs.cs
- WebZone.cs
- SqlCachedBuffer.cs
- SystemNetworkInterface.cs
- GeometryCombineModeValidation.cs