A
A
akass2016-03-22 21:03:54
.NET
akass, 2016-03-22 21:03:54

Show how to use TPL?

I’m learning TPL and I’m already confused, tell me what is better to use if I have a collection of arrays and I need to process them all (read only, I don’t change) with the ability to display progress in the ProgressBar and with the ability to Stop / Pause / Continue ? Tried to add Parallel.Foreach to Task but it didn't work.
I roughly imagine this as a Task , in which arrays are processed in Parallel.Foreach in parallel, periodically updating the ProgressBar through Iprogress. So in principle it works, but how is it all right to Stop / Suspend / Continue?
Tried to use ParallelLoopState and CancelationToken to stop, but it's somehow crooked.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Pavlov, 2016-03-23
@akass

I think Parallel.Foreach is out of place here - see Pause and Resume in Parallel.Foreach
Try using Task and PauseToken - see Cooperatively pausing async methods

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question