I need to execute two methods simultaneously, only after completion of this next thing should continue, the problem i have a UI which throws me error if use task (Its a WPF appliation).
Task Data= Task.Factory.StartNew(() => Readdetails());
Task Data2= Task.Factory.StartNew(() => ReadProcedure());
Data.Wait();
Data2.Wait();
but i am getting Error(must-create-dependencysource-on-same-thread-as-dependencyobject).
something like this i need.
private void ReadProcedure()
{
this.Pro = //some stuff;
}
private void ReadProcedure2()
{
this.Pro2 = //some stuff;
}
if(this.pro!=null && this.pro2!=null)
{
//other things to carry out.
}
I tried using Dispacter but it seems it's still not working.
To wait for multiple task, you can your Task.WaitAll.
To update on UI, you can use synchronizationcontext.
You can combine above two, using TaskFactory.ContinueWhenAll.