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
- LabelAutomationPeer.cs
- KeyToListMap.cs
- PropertyDescriptorComparer.cs
- TextBox.cs
- FileSystemEventArgs.cs
- GroupItemAutomationPeer.cs
- RegistryConfigurationProvider.cs
- Size.cs
- RegexGroupCollection.cs
- HierarchicalDataBoundControl.cs
- ToolStripProgressBar.cs
- SafeEventHandle.cs
- ActivityInstance.cs
- EventDescriptor.cs
- PropertySegmentSerializationProvider.cs
- DefaultCommandConverter.cs
- DataContractFormatAttribute.cs
- SegmentTree.cs
- StrokeNodeEnumerator.cs
- Attributes.cs
- DesignTimeVisibleAttribute.cs
- HtmlToClrEventProxy.cs
- DocumentViewerHelper.cs
- InvalidContentTypeException.cs
- ZoneMembershipCondition.cs
- SqlMetaData.cs
- ReadOnlyTernaryTree.cs
- GridToolTip.cs
- AttachedAnnotationChangedEventArgs.cs
- _HelperAsyncResults.cs
- RadioButton.cs
- FocusTracker.cs
- WebServiceClientProxyGenerator.cs
- MDIClient.cs
- HashCoreRequest.cs
- BuildProviderAppliesToAttribute.cs
- StateWorkerRequest.cs
- Command.cs
- NativeMethods.cs
- TimeStampChecker.cs
- DataViewListener.cs
- TemplateControlParser.cs
- DiscoveryService.cs
- CollectionChangeEventArgs.cs
- WebBrowserBase.cs
- TemplateBaseAction.cs
- PhysicalAddress.cs
- ArrayTypeMismatchException.cs
- BaseCodePageEncoding.cs
- DelegateCompletionCallbackWrapper.cs
- EnumUnknown.cs
- BaseUriHelper.cs
- SafeArchiveContext.cs
- CalendarAutomationPeer.cs
- SubclassTypeValidator.cs
- Logging.cs
- SQLBinary.cs
- SByteStorage.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- DataPagerFieldItem.cs
- MemberPathMap.cs
- SpeechRecognitionEngine.cs
- webeventbuffer.cs
- SystemIPGlobalStatistics.cs
- FontCacheLogic.cs
- RecognizeCompletedEventArgs.cs
- BindingManagerDataErrorEventArgs.cs
- SyntaxCheck.cs
- WaitHandleCannotBeOpenedException.cs
- SqlCharStream.cs
- WebPartManager.cs
- EditorPart.cs
- XamlUtilities.cs
- MetadataExchangeBindings.cs
- TemplateBuilder.cs
- SQLString.cs
- GenerateScriptTypeAttribute.cs
- InputScope.cs
- HWStack.cs
- DesignerToolboxInfo.cs
- BindStream.cs
- SystemIPInterfaceProperties.cs
- ParallelTimeline.cs
- StructuredType.cs
- SmtpDigestAuthenticationModule.cs
- Membership.cs
- ScrollPatternIdentifiers.cs
- versioninfo.cs
- ToolStripComboBox.cs
- SiteMapDesignerDataSourceView.cs
- InvalidOperationException.cs
- validation.cs
- SqlBinder.cs
- ApplicationDirectoryMembershipCondition.cs
- FrameSecurityDescriptor.cs
- WebConfigurationHostFileChange.cs
- ToolStripTextBox.cs
- TableLayoutPanelDesigner.cs
- StringFunctions.cs
- MatrixTransform.cs