I am in desperate to find a solution to my problem.
Following is the code which generates different task for each item in List
This might be a lambda scope problem.
Have you tried to assign the viewModel to a local variable before passing it to the StartNew method
...
Task validateMarked = Task.Factory.StartNew(() =>
{
foreach (AccountContactViewModel viewModel in selectedDataList)
{
var localViewModel = viewModel;
if (localViewModel != null)
{
Task validate = Task.Factory.StartNew(
() => ValidateAccount(localViewModel),
(TaskCreationOptions)TaskContinuationOptions.AttachedToParent);
}
}
});
...