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
- CodeGotoStatement.cs
- EndOfStreamException.cs
- DataGridSortCommandEventArgs.cs
- ValueHandle.cs
- Win32.cs
- ScriptReferenceEventArgs.cs
- BindingGraph.cs
- SelectionItemProviderWrapper.cs
- InitializerFacet.cs
- IndexedDataBuffer.cs
- MetadataReference.cs
- CharAnimationUsingKeyFrames.cs
- ImportContext.cs
- ContentHostHelper.cs
- WebEventCodes.cs
- TableStyle.cs
- Part.cs
- FixedSOMTable.cs
- ContextDataSourceView.cs
- WebEventCodes.cs
- RadioButton.cs
- ValueTypeFixupInfo.cs
- ExpandoObject.cs
- XamlHttpHandlerFactory.cs
- DesignTimeVisibleAttribute.cs
- MobileCapabilities.cs
- BrushValueSerializer.cs
- SoapHeader.cs
- PersonalizationAdministration.cs
- SqlBuilder.cs
- FlowDocumentFormatter.cs
- PasswordTextNavigator.cs
- Tablet.cs
- RenderingEventArgs.cs
- ItemContainerGenerator.cs
- HashCodeCombiner.cs
- FormClosingEvent.cs
- Activator.cs
- XmlSecureResolver.cs
- LayoutManager.cs
- SHA1CryptoServiceProvider.cs
- DataGridViewComboBoxEditingControl.cs
- GenericTypeParameterBuilder.cs
- SignedXml.cs
- ModifiableIteratorCollection.cs
- ResizeGrip.cs
- CryptoStream.cs
- OperatingSystem.cs
- PersonalizationStateInfoCollection.cs
- DiagnosticEventProvider.cs
- TdsRecordBufferSetter.cs
- RowToParametersTransformer.cs
- TypeToArgumentTypeConverter.cs
- BoundField.cs
- TypeTypeConverter.cs
- Accessible.cs
- Base64Encoder.cs
- IncrementalHitTester.cs
- LocalBuilder.cs
- XhtmlBasicSelectionListAdapter.cs
- DbgCompiler.cs
- XmlILTrace.cs
- TextRangeEditTables.cs
- UnauthorizedWebPart.cs
- ValueSerializer.cs
- UnsafeNativeMethodsPenimc.cs
- WebHttpBehavior.cs
- RecordsAffectedEventArgs.cs
- RemotingConfigParser.cs
- FormsAuthenticationTicket.cs
- InstanceNotReadyException.cs
- GregorianCalendar.cs
- URLString.cs
- RuntimeResourceSet.cs
- DropShadowEffect.cs
- BamlTreeNode.cs
- StyleBamlTreeBuilder.cs
- HostedTransportConfigurationBase.cs
- EncoderReplacementFallback.cs
- DigitShape.cs
- DbSourceCommand.cs
- DataSourceExpression.cs
- EnlistmentTraceIdentifier.cs
- RemotingConfigParser.cs
- HierarchicalDataBoundControl.cs
- JavascriptXmlWriterWrapper.cs
- RelOps.cs
- DesignerActionUI.cs
- QilDataSource.cs
- RoutingConfiguration.cs
- StylusPointCollection.cs
- OutputCacheProfileCollection.cs
- PartialCachingAttribute.cs
- BinaryConverter.cs
- SevenBitStream.cs
- DecimalAverageAggregationOperator.cs
- MULTI_QI.cs
- AsyncResult.cs
- XmlNode.cs
- TextEditorMouse.cs