Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / ndp / clr / src / BCL / System / Runtime / Remoting / LeaseManager.cs / 1 / LeaseManager.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== //+---------------------------------------------------------------------------- // // Microsoft Windows // File: LeaseManager.cs // // Contents: Administers the leases in an appdomain // // History: 1/5/00[....] Created // //+--------------------------------------------------------------------------- namespace System.Runtime.Remoting.Lifetime { using System; using System.Collections; using System.Threading; internal class LeaseManager { // Lease Lists private Hashtable leaseToTimeTable = new Hashtable(); // Async Sponsor Calls //private SortedList sponsorCallList = new SortedList(); private Hashtable sponsorTable = new Hashtable(); // LeaseTimeAnalyzer thread private TimeSpan pollTime; AutoResetEvent waitHandle; TimerCallback leaseTimeAnalyzerDelegate; private volatile Timer leaseTimer; internal static bool IsInitialized() { DomainSpecificRemotingData remotingData = Thread.GetDomain().RemotingData; LeaseManager leaseManager = remotingData.LeaseManager; return leaseManager != null; } internal static LeaseManager GetLeaseManager(TimeSpan pollTime) { DomainSpecificRemotingData remotingData = Thread.GetDomain().RemotingData; LeaseManager leaseManager = remotingData.LeaseManager; if (leaseManager == null) { lock (remotingData) { if (remotingData.LeaseManager == null) { remotingData.LeaseManager = new LeaseManager(pollTime); } leaseManager = remotingData.LeaseManager; } } return leaseManager; } internal static LeaseManager GetLeaseManager() { DomainSpecificRemotingData remotingData = Thread.GetDomain().RemotingData; LeaseManager leaseManager = remotingData.LeaseManager; BCLDebug.Assert(leaseManager != null, "[LeaseManager.GetLeaseManager()]leaseManager !=null"); return leaseManager; } private LeaseManager(TimeSpan pollTime) { BCLDebug.Trace("REMOTE","LeaseManager Constructor"); this.pollTime = pollTime; leaseTimeAnalyzerDelegate = new TimerCallback(this.LeaseTimeAnalyzer); waitHandle = new AutoResetEvent(false); // We need to create a Timer with Infinite dueTime to ensure that // leaseTimeAnalyzerDelegate doesnt get invoked before leaseTimer is initialized // Once initialized we can change it to the appropriate dueTime leaseTimer = new Timer(leaseTimeAnalyzerDelegate, null, Timeout.Infinite, Timeout.Infinite); leaseTimer.Change((int)pollTime.TotalMilliseconds, Timeout.Infinite); } internal void ChangePollTime(TimeSpan pollTime) { BCLDebug.Trace("REMOTE","LeaseManager ChangePollTime ", pollTime); this.pollTime = pollTime; } internal void ActivateLease(Lease lease) { BCLDebug.Trace("REMOTE","LeaseManager AddLease ",lease.id," ",lease.managedObject); lock(leaseToTimeTable) { leaseToTimeTable[lease] = lease.leaseTime; } } internal void DeleteLease(Lease lease) { BCLDebug.Trace("REMOTE","LeaseManager DeleteLease ",lease.id); lock(leaseToTimeTable) { leaseToTimeTable.Remove(lease); } } [System.Diagnostics.Conditional("_LOGGING")] internal void DumpLeases(Lease[] leases) { for (int i=0; i
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RotateTransform3D.cs
- CursorInteropHelper.cs
- EnumDataContract.cs
- SafeSystemMetrics.cs
- IntellisenseTextBox.cs
- IgnoreFileBuildProvider.cs
- Menu.cs
- WindowsProgressbar.cs
- NavigationEventArgs.cs
- Quaternion.cs
- EventBindingService.cs
- FixedBufferAttribute.cs
- CustomAttributeBuilder.cs
- SecurityTraceRecordHelper.cs
- DataServiceQueryOfT.cs
- DragDeltaEventArgs.cs
- SignedXml.cs
- WindowsRichEditRange.cs
- ConsumerConnectionPointCollection.cs
- ClientScriptManager.cs
- ByteAnimationBase.cs
- CommandManager.cs
- ToolStripDropDownItem.cs
- AlternationConverter.cs
- ObservableDictionary.cs
- TraceHandlerErrorFormatter.cs
- DebugView.cs
- HwndHostAutomationPeer.cs
- SymmetricCryptoHandle.cs
- QilBinary.cs
- EntityContainerAssociationSetEnd.cs
- RenderData.cs
- WindowsProgressbar.cs
- ExpressionBuilderContext.cs
- fixedPageContentExtractor.cs
- WebServiceParameterData.cs
- EventTrigger.cs
- XmlEncoding.cs
- Parameter.cs
- ParserContext.cs
- Int32RectConverter.cs
- webeventbuffer.cs
- Tuple.cs
- MenuItemStyleCollection.cs
- FixUp.cs
- PropertyHelper.cs
- ListSourceHelper.cs
- ExtendedProtectionPolicy.cs
- VisualState.cs
- MetadataSource.cs
- WmlTextViewAdapter.cs
- AssemblyHash.cs
- DictionaryEditChange.cs
- MachineSettingsSection.cs
- XmlSchemaDocumentation.cs
- InternalRelationshipCollection.cs
- UTF32Encoding.cs
- LoginName.cs
- ExtensionElement.cs
- AutomationPeer.cs
- DefaultSettingsSection.cs
- TableCell.cs
- EmbeddedMailObject.cs
- BufferedGraphics.cs
- CodeAttributeArgument.cs
- WorkflowInstance.cs
- XmlMapping.cs
- NameObjectCollectionBase.cs
- RotateTransform3D.cs
- TakeQueryOptionExpression.cs
- SubMenuStyleCollection.cs
- BinHexDecoder.cs
- OutputWindow.cs
- AssemblyInfo.cs
- Socket.cs
- EntityDataSourceValidationException.cs
- handlecollector.cs
- Exceptions.cs
- VolatileEnlistmentMultiplexing.cs
- TreeViewCancelEvent.cs
- ProvidePropertyAttribute.cs
- DataStreamFromComStream.cs
- ContourSegment.cs
- CngKey.cs
- TripleDESCryptoServiceProvider.cs
- DataControlFieldCollection.cs
- DataPagerCommandEventArgs.cs
- BitStack.cs
- FileUtil.cs
- SelectManyQueryOperator.cs
- InvalidAsynchronousStateException.cs
- EntityDataSource.cs
- processwaithandle.cs
- SchemaImporterExtensionsSection.cs
- WpfMemberInvoker.cs
- TraceHandler.cs
- ResourceReferenceExpression.cs
- CodeNamespaceCollection.cs
- PermissionAttributes.cs
- NativeRecognizer.cs