First of all, your ActionBlock
don't have to change the CurrentProgress
property directly.
The reason is that the RaisePropertyChanged
function will directly run code of the ProgressBar
Object.
Which is not allowed as it's an Object owned by the UIThread.
The ActionBlock
run in his own thread, and he need to post the progressBar update order to the UI Thread (by using the Dispatcher.BeginInvoke
) :
ActionBlock<object>(
temp =>
{
double progress = (double)temp.RecordNumber/(double)TotalRecords;
Dispatcher.BeginInvoke((Action)(() =>
{
CurrentProgress = progress;
}));
},
new ExecutionDataflowBlockOptions
{
TaskScheduler = TaskScheduler.FromCurrentSynchronizationContext()
});
You'll have to change this first thing for sure in order to make what you want.
Secondly (if this does not change anything), you have to check that your UI Thread is not waiting for the completion of your TransformBlock
. If your ICommand
(if you're calling it from a button for exemple) is not ASync and do something like this :
transformBlock.Completion.Wait();
It's not ok. Because your UIThread will wait for the end of your treatment and will not take the previous progressBar update orders until the end.
Good luck ! Please post new details if it's alway not working.