Private void btnStart_Click (object sender, EventArgs e)
{
Thread threadWork=new Thread (new ThreadStart (enclosing ReturnState));
ThreadWork. Start ();
ThreadWork. IsBackground=true;
}
Public void ReturnState ()
{
While (true)
{
Thread.sleep (1);
The if ()
.
}
}
CodePudding user response:
1. ThreadWork. Start ();ThreadWork. IsBackground=true; Both a change of position
2. Click on the button to create a thread has no place to stop the thread thread more check internal thread whether there is leakage cause of memory or the thread interface controls where the internal thread to open more leads to interface card after death is not responding
CodePudding user response:
Thread used within the while (true) have effect?CodePudding user response:
First look at the log, the specific reason is whatSleep (1) to sleep (1000).
CodePudding user response:
General internal thread, to see whether the thread codeCodePudding user response:
I would rather use a timer based on thread back to use while (true), visual inspection is the logical problem in if statementsCodePudding user response:
In the visual IF lead to write codeCodePudding user response: