쓰레드에서 리스트박스, 텍스트박스 등을 사용하여 디버깅 안될 때
에러 메시지
Additional information: Cross-thread operation not valid: Control 'textbox1'
accessed from a thread other than the thread it was created on.
결과 찾은 곳
http://stackoverflow.com/questions/10775367/cross-thread-operation-not-
valid-control-textbox1-accessed-from-a-thread-othe
//내가 해결한 소스
delegate void SetTextCallback(string text,TextBox t);
private void SetText(string text, TextBox t)
{
// InvokeRequired required compares the thread ID of the
// calling thread to the thread ID of the creating thread.
// If these threads are different, it returns true.
if (t.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] { text,t });
}
else
{
t.Text = text;
}
}
SetText(Math.Round(color.GetHue(),1).ToString(), textBox_h);
SetText(Math.Round((color.GetSaturation() * 255.0f), 0).ToString(), textBox_s);
SetText(Math.Round((color.GetBrightness() * 255.0f), 0).ToString(), textBox_v);