Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// 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(); } } } // 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
- HtmlTextArea.cs
- AttributeCollection.cs
- XmlBinaryWriter.cs
- InternalControlCollection.cs
- IfElseDesigner.xaml.cs
- Int32RectConverter.cs
- SqlAggregateChecker.cs
- Method.cs
- PartialArray.cs
- ToolStripItemImageRenderEventArgs.cs
- ClickablePoint.cs
- PropertyGeneratedEventArgs.cs
- SchemaTableColumn.cs
- WindowsSysHeader.cs
- PersonalizationProviderHelper.cs
- Rect3DConverter.cs
- EntityType.cs
- TraceHandler.cs
- SqlParameter.cs
- MouseCaptureWithinProperty.cs
- PromptStyle.cs
- SecurityContextTokenCache.cs
- webproxy.cs
- FontSourceCollection.cs
- XmlSchemaInclude.cs
- GeometryValueSerializer.cs
- SecurityStandardsManager.cs
- WindowsTab.cs
- FtpCachePolicyElement.cs
- TreeNodeBindingCollection.cs
- templategroup.cs
- BeginSelectCardRequest.cs
- PermissionSetEnumerator.cs
- CodeVariableReferenceExpression.cs
- BamlBinaryReader.cs
- StreamUpgradeAcceptor.cs
- OdbcParameterCollection.cs
- unsafenativemethodstextservices.cs
- DataServiceHost.cs
- CodeMethodMap.cs
- PropertyTab.cs
- ToolBarPanel.cs
- InheritedPropertyDescriptor.cs
- SafeFreeMibTable.cs
- MimeBasePart.cs
- HwndSource.cs
- Walker.cs
- DictionaryContent.cs
- DataGridViewAdvancedBorderStyle.cs
- DeclarativeCatalogPartDesigner.cs
- ListView.cs
- RegexWorker.cs
- MatrixAnimationBase.cs
- TextTreeTextBlock.cs
- RenderDataDrawingContext.cs
- _emptywebproxy.cs
- SqlHelper.cs
- CodeTypeReferenceExpression.cs
- UdpContractFilterBehavior.cs
- ProfileManager.cs
- XPathNavigator.cs
- ResourceDisplayNameAttribute.cs
- Cursors.cs
- Mouse.cs
- LocalValueEnumerator.cs
- XAMLParseException.cs
- AddInControllerImpl.cs
- SafeJobHandle.cs
- DecimalConstantAttribute.cs
- XmlCollation.cs
- XmlCharCheckingWriter.cs
- TraceSwitch.cs
- ProjectionPathSegment.cs
- WebPartConnectionsCloseVerb.cs
- Transactions.cs
- WindowsStatusBar.cs
- WsdlParser.cs
- DataContractJsonSerializerOperationFormatter.cs
- AspNetSynchronizationContext.cs
- SoapAttributeOverrides.cs
- PermissionSet.cs
- HtmlContainerControl.cs
- SQLRoleProvider.cs
- PtsPage.cs
- QueryableDataSourceView.cs
- TrackBar.cs
- DataServiceHostFactory.cs
- DoubleAnimationClockResource.cs
- SamlConstants.cs
- WindowsGraphicsCacheManager.cs
- Literal.cs
- DesignTimeParseData.cs
- TextDecorationCollection.cs
- ExtendedPropertyDescriptor.cs
- AssociationType.cs
- CacheDict.cs
- MetadataImporterQuotas.cs
- FolderBrowserDialog.cs
- FakeModelItemImpl.cs
- OutOfMemoryException.cs