Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Runtime / Remoting / ClientSponsor.cs / 1305376 / 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; [System.Security.SecurityCritical] // auto-generated_required [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;} } [System.Security.SecurityCritical] // auto-generated 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; } [System.Security.SecurityCritical] // auto-generated 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 [System.Security.SecurityCritical] public TimeSpan Renewal(ILease lease) { BCLDebug.Trace("REMOTE", "ClientSponsor Renewal "+m_renewalTime); return m_renewalTime; } [System.Security.SecurityCritical] // auto-generated 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 [System.Security.SecurityCritical] public override Object InitializeLifetimeService() { return null; } [System.Security.SecuritySafeCritical] // finalizers should be treated as safe ~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; [System.Security.SecurityCritical] // auto-generated_required [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;} } [System.Security.SecurityCritical] // auto-generated 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; } [System.Security.SecurityCritical] // auto-generated 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 [System.Security.SecurityCritical] public TimeSpan Renewal(ILease lease) { BCLDebug.Trace("REMOTE", "ClientSponsor Renewal "+m_renewalTime); return m_renewalTime; } [System.Security.SecurityCritical] // auto-generated 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 [System.Security.SecurityCritical] public override Object InitializeLifetimeService() { return null; } [System.Security.SecuritySafeCritical] // finalizers should be treated as safe ~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
- ColumnReorderedEventArgs.cs
- SafeSecurityHandles.cs
- UserControlBuildProvider.cs
- EventTrigger.cs
- KeyProperty.cs
- _Connection.cs
- InvalidComObjectException.cs
- ToolZone.cs
- DynamicValidatorEventArgs.cs
- DBCSCodePageEncoding.cs
- FixedNode.cs
- XmlSchemaSimpleTypeRestriction.cs
- SystemNetworkInterface.cs
- ContentElement.cs
- DataRecordObjectView.cs
- QuadraticEase.cs
- WebPartCollection.cs
- DockPatternIdentifiers.cs
- BaseTemplateBuildProvider.cs
- ObjectListDesigner.cs
- ConstantCheck.cs
- SocketException.cs
- TimeIntervalCollection.cs
- ChangePassword.cs
- GeneralTransform3D.cs
- CodeAttributeArgumentCollection.cs
- StoreContentChangedEventArgs.cs
- ScrollContentPresenter.cs
- LineBreakRecord.cs
- ExceptionNotification.cs
- DbProviderFactoriesConfigurationHandler.cs
- TdsParserStaticMethods.cs
- WorkerRequest.cs
- DbCommandTree.cs
- BuildResult.cs
- SqlServices.cs
- mda.cs
- StandardMenuStripVerb.cs
- SortKey.cs
- VariableQuery.cs
- shaperfactoryquerycachekey.cs
- XmlWrappingReader.cs
- VSDExceptions.cs
- SoapReflectionImporter.cs
- documentsequencetextview.cs
- SafeReversePInvokeHandle.cs
- TableProvider.cs
- BitStack.cs
- mediaeventshelper.cs
- CharacterHit.cs
- CultureTable.cs
- DNS.cs
- Span.cs
- TextModifierScope.cs
- HttpListenerTimeoutManager.cs
- NodeFunctions.cs
- UpdatableWrapper.cs
- SizeKeyFrameCollection.cs
- StaticDataManager.cs
- SqlResolver.cs
- EventDrivenDesigner.cs
- LinqToSqlWrapper.cs
- QueryStringHandler.cs
- SpoolingTask.cs
- RegistryDataKey.cs
- IdentityManager.cs
- XmlAnyElementAttribute.cs
- SmtpNegotiateAuthenticationModule.cs
- Point4DValueSerializer.cs
- DataErrorValidationRule.cs
- InsufficientExecutionStackException.cs
- GroupBox.cs
- WebColorConverter.cs
- RoutedCommand.cs
- CompositeDuplexElement.cs
- RoleGroup.cs
- CSharpCodeProvider.cs
- HashAlgorithm.cs
- CredentialCache.cs
- GPStream.cs
- EventProvider.cs
- DecoderReplacementFallback.cs
- ServiceInfo.cs
- CodeMemberMethod.cs
- ContextMenuAutomationPeer.cs
- SelectionHighlightInfo.cs
- DelegateArgument.cs
- PersistenceContext.cs
- ZoneIdentityPermission.cs
- BeginStoryboard.cs
- PackageRelationshipCollection.cs
- safex509handles.cs
- EntityDataSourceDataSelection.cs
- SqlConnectionHelper.cs
- ApplicationSecurityManager.cs
- TagMapInfo.cs
- AnnotationAdorner.cs
- ISessionStateStore.cs
- QueryAccessibilityHelpEvent.cs
- SqlReferenceCollection.cs