C# equlivent of performSelectorOnMainThread
Posted
by jamone
on Stack Overflow
See other posts from Stack Overflow
or by jamone
Published on 2010-03-17T14:10:32Z
Indexed on
2010/03/17
14:11 UTC
Read the original article
Hit count: 359
c#
|multithreading
I haven't done much multithreading before and now find the need to do some background work and keep the UI responsive. I have the following code.
data.ImportProgressChanged += new
DataAccess.ImportDelegate(data_ImportProgressChanged);
Thread importThread = new Thread(
new ThreadStart(data.ImportPeopleFromFAD));
importThread.IsBackground = true;
importThread.Start();
void data_ImportProgressChanged(int progress)
{
toolStripProgressBar.Value = progress;
}
//In my data object I have
public void ImportPeopleFromFAD()
{
ImportProgressChanged(someInt);
}
But the UI doesn't get updated since the ImportProgressChanged()
call is made on the background thread. In objective C I know you can use performSelectorOnMainThread and pass it a method to call using the main thread. What is the equivalent way of calling ImportProgressChanged()
from the main thread?
© Stack Overflow or respective owner