Skip to content

MultiThread in C#

Nguyen Duc Hoa

Nguyen Duc Hoa

Asked May 19, 2007, 10:49 AM EDT1 answer
Share
LinkedInX
Hello everybody. I have a question. I'm using C# on Microsoft Visual Studio 2005. I have a function (Search). An a cmd_SingleThread button has code { Search(); } When I click, everything is OK but I have second button, called MultiThread button has code { Thread th=new Thread(ThreadStart(Search)); th.Start(); } When I click this button, it always inform a Exception called InvalidOperationException. "Cross-thread operation not valid: Control 'listBox1' accessed from a thread other than the thread it was created on." Can you explain? Thank you

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    i doubt u can reference an object in the main thread from a subthread. have u tried using a delegate as go between?
    0