Trying to use task.factory on a method
I'm trying to keep the main UI from locking up while I do a DB lookup in the background. I'm assuming this can be done with threading. I tried this Task.Factory.StartNew(()=>Method(string,string,string) but I get a message about crossthreading because the method is getting the value of a combo box. How do I avoid this?

VulpesRank #55 · 29.2K reputationPosted Sep 19, 2011, 6:15 AM EDT
Jason31 reputationPosted Sep 19, 2011, 6:27 AM EDT
if...
{
Method(string,string)
}
I changed it to
if...
{
Task.Factory.StartNew(()=>Method(string,string));
}}
Method(string, string)
{
if(cmb1.SelectedItem.ToString() == "Stuff")
Do stuff here
}
Also on a different note I used Parallel.Invoke() successfully but is there a way to do parallel without making a bunch of methods? I had a list of combo boxes that set datasources from queries I pulled them out of the main method and made a new method for each one, that works but is there a way to do it without making the new methods?
VulpesRank #55 · 29.2K reputationPosted Sep 19, 2011, 6:57 AM EDT
Jason31 reputationPosted Sep 19, 2011, 7:09 AM EDT
Sam HobbsRank #108 · 20.5K reputationPosted Sep 19, 2011, 2:09 PM EDT