Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / 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 sync 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"); } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DecoderBestFitFallback.cs
- InstanceOwnerException.cs
- MsmqReceiveHelper.cs
- PrefixQName.cs
- OleDbReferenceCollection.cs
- SizeF.cs
- XmlTextReader.cs
- milexports.cs
- ErrorRuntimeConfig.cs
- ServerIdentity.cs
- PowerModeChangedEventArgs.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- RangeValidator.cs
- DependencySource.cs
- X509ClientCertificateAuthentication.cs
- AnchoredBlock.cs
- SmtpReplyReader.cs
- MsmqTransportSecurity.cs
- NegationPusher.cs
- EmptyCollection.cs
- ContractHandle.cs
- IBuiltInEvidence.cs
- ObjectQueryExecutionPlan.cs
- UrlPath.cs
- ResourceProviderFactory.cs
- XmlQueryType.cs
- XmlSchemaAttributeGroupRef.cs
- DataGridViewCellStyleChangedEventArgs.cs
- PackUriHelper.cs
- FontDifferentiator.cs
- Button.cs
- XmlSchemaObjectCollection.cs
- SafeFileMapViewHandle.cs
- Rfc4050KeyFormatter.cs
- SafeArchiveContext.cs
- CustomDictionarySources.cs
- UnsafeNativeMethods.cs
- UserControlCodeDomTreeGenerator.cs
- ChainedAsyncResult.cs
- Exception.cs
- Nullable.cs
- TemplateField.cs
- TypedTableHandler.cs
- SymbolUsageManager.cs
- TcpAppDomainProtocolHandler.cs
- Region.cs
- QilName.cs
- mediaeventargs.cs
- TextParentUndoUnit.cs
- WebPartConnectionsConnectVerb.cs
- OdbcDataReader.cs
- ServiceCredentials.cs
- Group.cs
- ReferenceList.cs
- DispatcherHooks.cs
- DataGrid.cs
- InvalidComObjectException.cs
- CompositeActivityValidator.cs
- WindowsProgressbar.cs
- DropShadowEffect.cs
- HttpCapabilitiesEvaluator.cs
- ToolStripDropDownMenu.cs
- PersonalizationDictionary.cs
- Setter.cs
- AutomationProperty.cs
- ResolveMatchesApril2005.cs
- BezierSegment.cs
- LicenseException.cs
- ToolStripDropDownDesigner.cs
- PolyLineSegment.cs
- RoleGroupCollectionEditor.cs
- SettingsPropertyCollection.cs
- MsmqOutputChannel.cs
- InvalidEnumArgumentException.cs
- PriorityBinding.cs
- XMLDiffLoader.cs
- WebContext.cs
- WebPartConnectionsCancelVerb.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- AssemblyHelper.cs
- SizeAnimationUsingKeyFrames.cs
- SQlBooleanStorage.cs
- CheckBox.cs
- CreateParams.cs
- PublisherIdentityPermission.cs
- SessionPageStateSection.cs
- HtmlControlDesigner.cs
- XmlDataProvider.cs
- HttpContext.cs
- DragDeltaEventArgs.cs
- KeyMatchBuilder.cs
- DesignerProperties.cs
- HTMLTextWriter.cs
- DoubleAnimationUsingKeyFrames.cs
- BasicExpressionVisitor.cs
- SendKeys.cs
- WebResourceAttribute.cs
- MeasurementDCInfo.cs
- DataGridToolTip.cs
- Membership.cs