Code:
/ FX-1434 / FX-1434 / 1.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
- GacUtil.cs
- Win32NamedPipes.cs
- Visitor.cs
- SQLDoubleStorage.cs
- ScriptIgnoreAttribute.cs
- HeaderedItemsControl.cs
- KeyEventArgs.cs
- Char.cs
- SmiGettersStream.cs
- EdmScalarPropertyAttribute.cs
- exports.cs
- SystemThemeKey.cs
- AndCondition.cs
- HashHelpers.cs
- BufferedGraphicsContext.cs
- DictionaryContent.cs
- RtfToken.cs
- _SslState.cs
- RectConverter.cs
- TypeConverter.cs
- InvalidWMPVersionException.cs
- WindowsSysHeader.cs
- DataException.cs
- ConstraintConverter.cs
- Wizard.cs
- SharedStatics.cs
- Int32AnimationBase.cs
- ClientSession.cs
- BrowserCapabilitiesFactoryBase.cs
- BuilderPropertyEntry.cs
- CodeGotoStatement.cs
- RowsCopiedEventArgs.cs
- MailAddressParser.cs
- TextMarkerSource.cs
- PointAnimationBase.cs
- TextRunCacheImp.cs
- RadialGradientBrush.cs
- SqlProvider.cs
- SearchForVirtualItemEventArgs.cs
- GeneralTransform3DCollection.cs
- HitTestDrawingContextWalker.cs
- GlyphTypeface.cs
- UIElement3D.cs
- WMIInterop.cs
- PolyLineSegment.cs
- BinaryReader.cs
- XPathPatternParser.cs
- Pts.cs
- ObjectResult.cs
- ProvidersHelper.cs
- ToolZone.cs
- __FastResourceComparer.cs
- Parallel.cs
- BlurEffect.cs
- SimpleExpression.cs
- DigitShape.cs
- VectorAnimationUsingKeyFrames.cs
- RangeBaseAutomationPeer.cs
- NavigationWindow.cs
- UInt64.cs
- IMembershipProvider.cs
- Menu.cs
- BinaryUtilClasses.cs
- WSAddressing10ProblemHeaderQNameFault.cs
- HttpResponseHeader.cs
- SettingsPropertyValueCollection.cs
- SecurityContext.cs
- ExtendedPropertyDescriptor.cs
- SchemaCollectionPreprocessor.cs
- MenuBindingsEditorForm.cs
- StyleSheetComponentEditor.cs
- X509UI.cs
- SharedPerformanceCounter.cs
- KeyGestureConverter.cs
- DragDrop.cs
- UriTemplateDispatchFormatter.cs
- KeyPullup.cs
- ListViewInsertEventArgs.cs
- ImageSource.cs
- LookupBindingPropertiesAttribute.cs
- StringUtil.cs
- WindowsFont.cs
- UshortList2.cs
- WebPartConnectionsCancelVerb.cs
- StateManagedCollection.cs
- XmlBaseReader.cs
- MessageLoggingFilterTraceRecord.cs
- FilteredDataSetHelper.cs
- IdnElement.cs
- XmlAutoDetectWriter.cs
- RotateTransform3D.cs
- EntityCommandCompilationException.cs
- TextBounds.cs
- DecimalAnimationUsingKeyFrames.cs
- SoapIgnoreAttribute.cs
- DataListItemEventArgs.cs
- SmtpFailedRecipientsException.cs
- BaseTemplateParser.cs
- ComponentEditorPage.cs
- OleDbRowUpdatedEvent.cs