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?
Sam HobbsPosted Sep 19, 2011, 6:09 PM
JasonPosted Sep 19, 2011, 11:09 AM
VulpesPosted Sep 19, 2011, 10:57 AM
JasonPosted Sep 19, 2011, 10:27 AM
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?
VulpesPosted Sep 19, 2011, 10:15 AM