المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on repair doesnt work



C# Programming
04-29-2010, 12:51 AM
hey, I had a cross thread exception...
then i rewrite the problematic part to the next one

private void calculateEuclidianThread()
{
CalculateDistance euclidianKNN = new EuclideanDistance_KNN();
euclidianKNN.stLabel += delegate(object sender, string className)
{
string[] s = className.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

if (dataGridView2.InvokeRequired)
dataGridView2.Invoke(new MethodInvoker(delegate {
dataGridView2.Rows.Add((object[])s);
}));
};
euclidianKNN.calculateDis(trainingSet, testSet);
}

but now it stucks when the event rises
what is the problem here ?

thanks