Click to expand
Sandcastle XML Comments Guide

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" />

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.

Note 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