1 /* ****************************************************************************
\r
3 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5 * This software is subject to the Microsoft Public License (Ms-PL).
\r
6 * A copy of the license can be found in the license.htm file included
\r
7 * in this distribution.
\r
9 * You must not remove this notice, or any other, from this software.
\r
11 * ***************************************************************************/
\r
13 namespace System.Web.Mvc {
\r
15 using System.Diagnostics.CodeAnalysis;
\r
16 using System.Web.Mvc.Async;
\r
18 [SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes",
\r
19 Justification = "Unsealed so that subclassed types can set properties in the default constructor.")]
\r
20 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
\r
21 public class AsyncTimeoutAttribute : ActionFilterAttribute {
\r
23 // duration is specified in milliseconds
\r
24 public AsyncTimeoutAttribute(int duration) {
\r
25 if (duration < -1) {
\r
26 throw Error.AsyncCommon_InvalidTimeout("duration");
\r
29 Duration = duration;
\r
32 public int Duration {
\r
37 public override void OnActionExecuting(ActionExecutingContext filterContext) {
\r
38 if (filterContext == null) {
\r
39 throw new ArgumentNullException("filterContext");
\r
42 IAsyncManagerContainer container = filterContext.Controller as IAsyncManagerContainer;
\r
43 if (container == null) {
\r
44 throw Error.AsyncCommon_ControllerMustImplementIAsyncManagerContainer(filterContext.Controller.GetType());
\r
47 container.AsyncManager.Timeout = Duration;
\r
49 base.OnActionExecuting(filterContext);
\r