Invoke(Action)을 활용하여 크로스 쓰레드 처리 방법
void LabelSetText(Label lbtemp, string stemp)
{
if (lbtemp.InvokeRequired)
{
lbtemp.Invoke(new Action<Label, string>(LabelSetText),lbtemp,stemp));
}
else
{
lbtemp.Text = stemp;
}
}
Invoke를 사용하면 편하지만, Await을 통한 UI 쓰레드 동기 처리를 하는 방식이 더 깔끔하다.