को यह समझाना मुश्किल स्थिति है। एक सेवा प्रक्रिया है जो 2 थ्रेड शुरू करती है, प्रत्येक थ्रेड हमेशा के लिए लूप करता है लेकिन पेलोड समाप्त होने के बाद प्रत्येक बार 5 मिनट तक सो जाता है।प्रक्रिया समाप्त हो जाता है कारण StackOverflowException
समस्या यह है कि मेरा दूसरा धागा पेलोड भी समाप्त होने से पहले समाप्त हो गया है, कोई स्पष्ट कारण नहीं है, और मैं अपवाद नहीं पकड़ सकता क्योंकि यह प्रतिनिधि प्रक्रिया के बाहर से ट्रिगर होता है?
कैसे समस्या को खोजने के लिए पर कोई सुझाव?
कोड ....
public void StartService()
{
ThreadStart stRecieve = new ThreadStart(DownloadNewMail);
ThreadStart stSend = new ThreadStart(SendNewMail);
senderThread = new Thread(stRecieve);
recieverThread = new Thread(stSend);
sendStarted = true;
recieveStarted = true;
senderThread.Start();
recieverThread.Start();
}
private void DownloadNewMail()
{
while(recieveStarted)
{
//Payload....
if (recieveStarted)
{
Thread.Sleep(new TimeSpan(0, confSettings.PollInterval, 0));
}
}
}
private void SendNewMail()
{
while(sendStarted)
{
//Payload....
if (sendStarted)
{
Thread.Sleep(new TimeSpan(0, confSettings.PollInterval, 0));
}
}
}
एक 'StackOverflowException' अक्सर बहुत गहरा, या परिपत्र instantiations द्वारा recursing के कारण होता है। क्या आप कहीं भी रिकर्सन का उपयोग कर रहे हैं? – LukeH
"प्रत्येक थ्रेड हमेशा के लिए loops" <- उस कोड को यहां पोस्ट करें –
हैव इसे स्थिर के रूप में धागे बनाकर हल करने में कामयाब रहे हैं ... –