Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / xsp / System / Web / IdleTimeoutMonitor.cs / 1 / IdleTimeoutMonitor.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* * Request timeout manager -- implements the request timeout mechanism */ namespace System.Web { using System.Threading; using System.Collections; using System.Web.Hosting; using System.Web.Util; internal class IdleTimeoutMonitor { private TimeSpan _idleTimeout; // the timeout value private DateTime _lastEvent; // idle since this time private Timer _timer; private readonly TimeSpan _timerPeriod = new TimeSpan(0, 0, 30); // 30 secs internal IdleTimeoutMonitor(TimeSpan timeout) { _idleTimeout = timeout; _timer = new Timer(new TimerCallback(this.TimerCompletionCallback), null, _timerPeriod, _timerPeriod); _lastEvent = DateTime.UtcNow; } internal void Stop() { // stop the timer if (_timer != null) { lock (this) { if (_timer != null) { ((IDisposable)_timer).Dispose(); _timer = null; } } } } internal DateTime LastEvent { // thread-safe property get { DateTime t; lock (this) { t = _lastEvent; } return t; } set { lock (this) { _lastEvent = value; } } } private void TimerCompletionCallback(Object state) { // user idle timer to trim the free list of app instanced HttpApplicationFactory.TrimApplicationInstances(); // no idle timeout if (_idleTimeout == TimeSpan.MaxValue) return; // don't do idle timeout if already shutting down if (HostingEnvironment.ShutdownInitiated) return; // check if there are active requests if (HostingEnvironment.BusyCount != 0) return; // check if enough time passed if (DateTime.UtcNow <= LastEvent.Add(_idleTimeout)) return; // check if debugger is attached if (System.Diagnostics.Debugger.IsAttached) return; // shutdown HttpRuntime.SetShutdownReason(ApplicationShutdownReason.IdleTimeout, SR.GetString(SR.Hosting_Env_IdleTimeout)); HostingEnvironment.InitiateShutdown(); } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Geometry3D.cs
- ExtendedTransformFactory.cs
- IdentityHolder.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- DynamicField.cs
- MetadataArtifactLoaderResource.cs
- Vector3D.cs
- HScrollProperties.cs
- TargetFrameworkAttribute.cs
- TextRangeEditLists.cs
- basecomparevalidator.cs
- Walker.cs
- TemplateControl.cs
- Subtree.cs
- NamespaceEmitter.cs
- FileSystemEventArgs.cs
- ConfigurationProviderException.cs
- MediaElementAutomationPeer.cs
- MatrixCamera.cs
- QilParameter.cs
- MailMessageEventArgs.cs
- SelectionItemPattern.cs
- IgnorePropertiesAttribute.cs
- DataGridViewCellLinkedList.cs
- BufferBuilder.cs
- BackStopAuthenticationModule.cs
- GraphicsPath.cs
- EntityDataSource.cs
- RemoteWebConfigurationHostStream.cs
- BufferedStream.cs
- Version.cs
- XmlName.cs
- SingleConverter.cs
- _CacheStreams.cs
- OdbcConnectionOpen.cs
- _DigestClient.cs
- StateMachineWorkflow.cs
- HwndSourceKeyboardInputSite.cs
- Style.cs
- CredentialCache.cs
- TableLayoutCellPaintEventArgs.cs
- ArgIterator.cs
- TypeSystemProvider.cs
- ArgumentValueSerializer.cs
- InstanceCompleteException.cs
- AmbientValueAttribute.cs
- TrackingValidationObjectDictionary.cs
- SqlProviderManifest.cs
- DataGridRelationshipRow.cs
- TrackingStringDictionary.cs
- Screen.cs
- PeerName.cs
- ListBoxItem.cs
- HtmlMeta.cs
- IntellisenseTextBox.designer.cs
- RelationshipConverter.cs
- CompleteWizardStep.cs
- LinkArea.cs
- ChildrenQuery.cs
- XmlSchemaSubstitutionGroup.cs
- ConfigurationValidatorAttribute.cs
- XmlnsCompatibleWithAttribute.cs
- ProfilePropertySettings.cs
- AccessibilityHelperForVista.cs
- Code.cs
- BitmapEffectInputData.cs
- Screen.cs
- columnmapfactory.cs
- Module.cs
- BufferModeSettings.cs
- LocatorPartList.cs
- ThicknessAnimation.cs
- RemotingConfiguration.cs
- X509CertificateCollection.cs
- Material.cs
- TabControl.cs
- PenCursorManager.cs
- FixedSOMPageElement.cs
- SigningProgress.cs
- FixedSOMPage.cs
- StringTraceRecord.cs
- HttpApplicationFactory.cs
- XmlElement.cs
- DataBindEngine.cs
- securitycriticaldata.cs
- Matrix3D.cs
- FieldBuilder.cs
- WebPartTransformer.cs
- ProgressPage.cs
- FrugalList.cs
- XmlDataDocument.cs
- FixedSOMImage.cs
- SqlPersonalizationProvider.cs
- FontStretchConverter.cs
- XsdDataContractExporter.cs
- DictionarySurrogate.cs
- SafeEventLogWriteHandle.cs
- DataServiceQueryProvider.cs
- XPathParser.cs
- AutoGeneratedFieldProperties.cs