Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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 [....] 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"); } } } // 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; [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"); } } } // 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
- SafeSecurityHandles.cs
- DataStreams.cs
- httpstaticobjectscollection.cs
- TimelineCollection.cs
- GuidelineCollection.cs
- designeractionbehavior.cs
- GridSplitter.cs
- ApplicationContext.cs
- NavigationHelper.cs
- FormattedText.cs
- GridViewUpdateEventArgs.cs
- SelfIssuedAuthRSAPKCS1SignatureDeformatter.cs
- input.cs
- cookiecollection.cs
- QueryTask.cs
- MILUtilities.cs
- ToolboxComponentsCreatedEventArgs.cs
- ReadWriteObjectLock.cs
- WebBrowser.cs
- XmlTextReaderImplHelpers.cs
- SessionEndingEventArgs.cs
- ObjectListCommand.cs
- PolicyAssertionCollection.cs
- CharEnumerator.cs
- WsdlBuildProvider.cs
- Cursor.cs
- XmlStreamStore.cs
- SeekStoryboard.cs
- EncodingTable.cs
- IntellisenseTextBox.designer.cs
- ToolStripDesigner.cs
- AppLevelCompilationSectionCache.cs
- CounterCreationDataCollection.cs
- DynamicResourceExtensionConverter.cs
- InstanceKeyView.cs
- CalendarDataBindingHandler.cs
- TcpClientSocketManager.cs
- InstalledFontCollection.cs
- SiteMap.cs
- Exception.cs
- XmlDownloadManager.cs
- BitmapEffectDrawingContextState.cs
- MultipleViewProviderWrapper.cs
- BinaryFormatterWriter.cs
- XmlDataDocument.cs
- ClaimTypeRequirement.cs
- smtppermission.cs
- HtmlInputText.cs
- NameSpaceEvent.cs
- ClientScriptManager.cs
- Floater.cs
- NavigatorOutput.cs
- PopupRoot.cs
- Int16Animation.cs
- RuleAction.cs
- DBCommand.cs
- CompressStream.cs
- HelpProvider.cs
- CheckBox.cs
- BaseCollection.cs
- GZipUtils.cs
- TypeResolver.cs
- HttpCookie.cs
- XmlSerializerNamespaces.cs
- HttpPostProtocolReflector.cs
- TextUtf8RawTextWriter.cs
- LinqDataSourceContextData.cs
- SeparatorAutomationPeer.cs
- Run.cs
- VariantWrapper.cs
- DataGridToolTip.cs
- HttpStreamMessageEncoderFactory.cs
- mediaeventargs.cs
- StrongNamePublicKeyBlob.cs
- ZipIOExtraFieldZip64Element.cs
- InfoCardProofToken.cs
- InputLanguageCollection.cs
- WeakHashtable.cs
- DelimitedListTraceListener.cs
- SqlProfileProvider.cs
- GeometryDrawing.cs
- TemplatedMailWebEventProvider.cs
- CustomAttribute.cs
- SimplePropertyEntry.cs
- AssemblyContextControlItem.cs
- Point3D.cs
- CollectionChangeEventArgs.cs
- ScriptReferenceEventArgs.cs
- RegexWriter.cs
- DBSchemaRow.cs
- CodeTypeDelegate.cs
- ScopelessEnumAttribute.cs
- SchemaElementLookUpTable.cs
- HttpDictionary.cs
- StackSpiller.Temps.cs
- ChannelServices.cs
- MarkupCompilePass2.cs
- SecurityRequiresReviewAttribute.cs
- TypeLoadException.cs
- followingsibling.cs