Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- CompilerParameters.cs
- ServiceObjectContainer.cs
- Vertex.cs
- DatePickerAutomationPeer.cs
- MultiBinding.cs
- QueryAccessibilityHelpEvent.cs
- BitmapDownload.cs
- AdjustableArrowCap.cs
- HtmlTableCellCollection.cs
- xml.cs
- WebScriptServiceHostFactory.cs
- Native.cs
- JapaneseCalendar.cs
- ControlPaint.cs
- ObjectDataProvider.cs
- DesignerCategoryAttribute.cs
- DataControlImageButton.cs
- ManagementEventWatcher.cs
- Emitter.cs
- DelegatingTypeDescriptionProvider.cs
- TableSectionStyle.cs
- DropDownButton.cs
- Positioning.cs
- PointAnimationClockResource.cs
- LocatorManager.cs
- WSHttpBindingElement.cs
- RubberbandSelector.cs
- WebPartActionVerb.cs
- Update.cs
- Int16AnimationBase.cs
- Keywords.cs
- WinInetCache.cs
- OperationCanceledException.cs
- ButtonColumn.cs
- ExceptionWrapper.cs
- ScriptingRoleServiceSection.cs
- RequiredFieldValidator.cs
- X509Extension.cs
- AttributeCollection.cs
- StylusPointProperties.cs
- webclient.cs
- DrawingVisual.cs
- Exception.cs
- _NTAuthentication.cs
- FixedSOMTextRun.cs
- DbConnectionStringBuilder.cs
- XmlDigitalSignatureProcessor.cs
- ErrorTableItemStyle.cs
- SqlTypeConverter.cs
- BufferedMessageWriter.cs
- Script.cs
- NameValuePermission.cs
- WorkflowMessageEventHandler.cs
- PageContentAsyncResult.cs
- ConnectionManagementElementCollection.cs
- SemaphoreSecurity.cs
- ToolStripItemCollection.cs
- ControlAdapter.cs
- TemplatedWizardStep.cs
- XmlLanguage.cs
- StorageEntitySetMapping.cs
- VerificationException.cs
- FormsAuthenticationConfiguration.cs
- ADConnectionHelper.cs
- DesignerForm.cs
- OdbcConnectionHandle.cs
- Pointer.cs
- GenericAuthenticationEventArgs.cs
- OleDbInfoMessageEvent.cs
- FaultDesigner.cs
- PartitionedStream.cs
- ServiceDescriptionReflector.cs
- StringToken.cs
- ZipFileInfoCollection.cs
- TransformedBitmap.cs
- WaitHandleCannotBeOpenedException.cs
- WebPartCloseVerb.cs
- ListViewGroup.cs
- GraphicsPathIterator.cs
- VectorValueSerializer.cs
- EventTrigger.cs
- Binding.cs
- SkipStoryboardToFill.cs
- WindowsIdentity.cs
- ReturnType.cs
- DesignColumnCollection.cs
- SiteIdentityPermission.cs
- WriterOutput.cs
- ObjectView.cs
- Events.cs
- ListControl.cs
- WbmpConverter.cs
- ECDsa.cs
- Keyboard.cs
- QuaternionAnimationBase.cs
- NameScopePropertyAttribute.cs
- ServiceDefaults.cs
- MessageQueueConverter.cs
- ResourcePermissionBase.cs
- DiscoveryServiceExtension.cs