Witam.. w aplikacji wielowątkowej serwera, przy dostępie do kontrolki ListView otrzymuje komunikat: 'Cross-thread operation not valid: Control 'listView1' accessed from a thread other than the thread it was created on'.
Rozumiem o co chodzi, ale nie wiem jak to zrobić na listView; poniżej przykład z MSDN'a dotyczący danego komunikatu dla textboxa.
Jak to powinno wyglądać dla ListView? chodzi mi o blok w warunku if..
Thread.Sleep(2000);
string text = "Written by the background thread.";
// Check if this method is running on a different thread
// than the thread that created the control.
if (this.textBox1.InvokeRequired)
{
// It's on a different thread, so use Invoke.
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke
(d, new object[] { text + " (Invoke)" });
}
else
{
// It's on the same thread, no need for Invoke
this.textBox1.Text = text + " (No Invoke)";
}