I upload images to the cloud Parallel execution:
var uiFactory = new TaskFactory(TaskScheduler.FromCurrentSynchronizationContext());
Parallel.ForEach(FinalFileNames,
new ParallelOptions { MaxDegreeOfParallelism = 4 },
path =>
{
count++;
double iPercentDone = (int)(((float)count / iTotalFiles) * 100);
uiFactory.StartNew(() =>
UploadProgress.Value = iPercentDone;
LblProgress.Content = count.ToString(CultureInfo.InvariantCulture)
+ " file(s) uploaded from " + iTotalFiles +
" file(s)";
}
});
The problem I am facing is that the user interface is blocked when I do this. The reason seems to work on the same topic.
If I complete this Parallel.ForEach in "Task.Factory.New", this will result in asynchronous calls, which is not my requirement.
Please let me know how I can fix the user interface block problem and also not make async calls.
source
share