समय-समय पर मुझे सिस्टम मिल जाता है। थ्रेडिंग। थ्रेडस्टेट अपवाद थ्रेड को पुनरारंभ करने का प्रयास करते समय। सवाल में कोड इस प्रकार है:थ्रेडस्टेट एक्सेप्शन एक थ्रेड को पुनरारंभ करने का प्रयास करते समय
// Make sure the thread is done stopping
while (this.mThread.ThreadState == ThreadState.Running)
{
Thread.Sleep(0);
}
// Respawn a thread if the current one is stopped or doesn't exist
if (this.mThread == null || this.mThread.ThreadState == ThreadState.Stopped)
{
this.mThread = new Thread(new ParameterizedThreadStart(Monitor)); }
// Start the thread
if (check)
{
this.mThread.Start(60000);
}
else
{
this.mThread.Start(0);
}
तो दो सवाल - इस काम करने का सही तरीका है, और यह है, वहाँ होने से त्रुटि से बचने के लिए एक रास्ता है?