private static aaa()
{
ThreadPool.QueueUserWorkItem(threadWorker,this);
}
private static void threadWorker(object obj)
{
Form1 f = (Form1)obj;
{
if (f.comboFrom.InvokeRequired)
{
f.comboFrom.Invoke(new ComboAddThreadSafeDelegate(ComboAddThreadSafe), f, ComboItem);
}
}
}
private delegate void ComboAddThreadSafeDelegate(Form1 f, String val);
private static void ComboAddThreadSafe(Form1 f, String val)
{
f.comboFrom.Items.Add(val);
}
//or
private static aaa()
{
Action<object> resultCallback = (theResults) =>
{
MessageBox.Show((string)theResults);
};
WaitCallback workItem = (dataOrSomeDetails) =>
{
string a = (string)dataOrSomeDetails;
resultCallback(a + " someResults");
};
ThreadPool.QueueUserWorkItem(workItem, "text");
}