Compartir a través de


TimeoutAttribute Class

Definition

Timeout attribute; used to specify the timeout of a unit test.

public ref class TimeoutAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false)]
public sealed class TimeoutAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Method)]
public sealed class TimeoutAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false)>]
type TimeoutAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Method)>]
type TimeoutAttribute = class
    inherit Attribute
Public NotInheritable Class TimeoutAttribute
Inherits Attribute
Inheritance
TimeoutAttribute
Attributes

Constructors

TimeoutAttribute(Int32)

Initializes a new instance of the TimeoutAttribute class.

TimeoutAttribute(TestTimeout)

Initializes a new instance of the TimeoutAttribute class with a preset timeout.

Properties

CooperativeCancellation

Gets or sets a value indicating whether the test method should be cooperatively canceled on timeout. When set to true, the cancellation token is canceled on timeout, and the method completion is awaited. The test method and all the code it calls, must be designed in a way that it observes the cancellation and cancels cooperatively. If the test method does not complete, the timeout does not force it to complete. When set to false, the cancellation token is canceled on timeout, timeout result is reported and the method task will continue running on background. This may lead to conflicts in file access on test cleanup, unobserved exceptions, and memory leaks.

Timeout

Gets the timeout in milliseconds.

Applies to