threadsafety

This element is used to indicate whether or not a class or structure's static and instance members are safe for use in multi-threaded scenarios.

Syntax

This top-level element is valid on all classes and structures.

 
<threadsafety static="true | false" instance="true | false" />

or

<threadsafety>Add a custom description of the type's thread safety</threadsafety>

The static attribute specifies whether static members of the class or structure are safe for use in multi-threaded operations. The instance attribute specifies whether instance members of the class or structure are safe for use in multi-threaded operations. If neither attribute is specified, it is the same as setting static to true and instance to false. Inner text can also be specified to describe the thread safety. If inner text is present, the attributes are ignored.

  Note

This is a custom XML comments element implemented by Sandcastle. It will not appear in the list of valid elements for XML comments IntelliSense.

Examples

 
/// <summary>
/// This class demonstrates the <c>threadsafety</c> XML comments element.
/// </summary>
/// <threadsafety static="true" instance="false" />
/// <conceptualLink target="fb4625cb-52d0-428e-9c7c-7a0d88e1b692" />
public class ThreadSafetyClass
{
    /// <summary>
    /// Per the <c>threadsafety</c> XML comments element on the class, the developer has
    /// indicated that static methods like this one are safe for multi-threaded use.
    /// </summary>
    /// <conceptualLink target="fb4625cb-52d0-428e-9c7c-7a0d88e1b692" />
    public static void StaticMethod()
    {
        // Thread-safe code goes here
    }

    /// <summary>
    /// Per the <c>threadsafety</c> XML comments element on the class, the developer has
    /// indicated that instance method like this one are not safe for multi-threaded use.
    /// </summary>
    /// <conceptualLink target="fb4625cb-52d0-428e-9c7c-7a0d88e1b692" />
    public void InstanceMethod()
    {
        // Non-thread-safe code goes here
    }
}

See Also

Reference

Other Resources