Skip to content

Gendarme.Rules.BadPractice.CheckNewThreadWithoutStartRule(2.10)

Sebastien Pouliot edited this page Jan 22, 2011 · 2 revisions

CheckNewThreadWithoutStartRule

Assembly: Gendarme.Rules.BadPractice
Version: 2.10

Description

This rule checks for threads which are created but not started, or returned or passed to another method as an argument.

Examples

Bad example:

void UnusedThread ()
{
    Thread thread = new Thread (threadStart);
    thread.Name = "Thread 1";
}

Good examples:

void Start ()
{
    Thread thread = new Thread (threadStart);
    thread.Name = "Thread 1";
    thread.Start ();
}
Thread InitializeThread ()
{
    Thread thread = new Thread (threadStart);
    thread.Name = "Thread 1";
    return thread;
}
Clone this wiki locally