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
- WrappedIUnknown.cs
- CodePropertyReferenceExpression.cs
- UndirectedGraph.cs
- WebBrowserSiteBase.cs
- XNodeValidator.cs
- entityreference_tresulttype.cs
- TextCollapsingProperties.cs
- securitymgrsite.cs
- SqlComparer.cs
- ColumnClickEvent.cs
- CompiledRegexRunner.cs
- BitmapEffectDrawing.cs
- CompilerState.cs
- Boolean.cs
- DropShadowEffect.cs
- SoapFault.cs
- ReplyChannel.cs
- HtmlElementCollection.cs
- HierarchicalDataBoundControl.cs
- CommentGlyph.cs
- CodeComment.cs
- EDesignUtil.cs
- _ContextAwareResult.cs
- DataTemplateKey.cs
- SmtpLoginAuthenticationModule.cs
- WebPartEditorCancelVerb.cs
- RemoteX509Token.cs
- URL.cs
- ApplicationGesture.cs
- CodeSnippetStatement.cs
- PackagePart.cs
- CryptoKeySecurity.cs
- HostSecurityManager.cs
- FixedTextView.cs
- ResourceSet.cs
- PeerNameRecordCollection.cs
- AvTraceFormat.cs
- AccessDataSourceView.cs
- BamlRecordHelper.cs
- TraceInternal.cs
- WebPartAddingEventArgs.cs
- DataExpression.cs
- ControllableStoryboardAction.cs
- XmlSerializerNamespaces.cs
- ProfileEventArgs.cs
- MimeMapping.cs
- OleDbDataAdapter.cs
- PingReply.cs
- BaseResourcesBuildProvider.cs
- RealProxy.cs
- DocumentPaginator.cs
- TextProperties.cs
- SqlProfileProvider.cs
- OdbcEnvironment.cs
- SamlAttributeStatement.cs
- CorrelationManager.cs
- PagerStyle.cs
- FacetDescriptionElement.cs
- BitmapEffectDrawing.cs
- ConnectionOrientedTransportElement.cs
- OperatorExpressions.cs
- X509Chain.cs
- IOThreadTimer.cs
- ObjectQuery.cs
- ExpressionPrefixAttribute.cs
- ErrorStyle.cs
- ObjectListDesigner.cs
- FacetDescription.cs
- ServicePointManager.cs
- CharConverter.cs
- Point3DCollectionValueSerializer.cs
- TransactedBatchingBehavior.cs
- DataGridViewCellParsingEventArgs.cs
- GcHandle.cs
- SettingsPropertyWrongTypeException.cs
- TablePattern.cs
- WorkflowServiceBehavior.cs
- ControlHelper.cs
- LogExtentCollection.cs
- ErrorLog.cs
- RedirectionProxy.cs
- DataView.cs
- BufferModeSettings.cs
- DetailsViewRowCollection.cs
- DataRowCollection.cs
- AsyncStreamReader.cs
- SafeFileMapViewHandle.cs
- XmlComment.cs
- ListSourceHelper.cs
- WindowsToolbarItemAsMenuItem.cs
- DesignerActionListCollection.cs
- DataError.cs
- LinqDataSourceHelper.cs
- TileBrush.cs
- BufferModesCollection.cs
- HttpEncoderUtility.cs
- basenumberconverter.cs
- XmlBinaryReader.cs
- ContentIterators.cs
- NamedObject.cs