c# - How to cancel parallel operation and return a partial list of result? -


i have long parallel operation done on list of data such:

list<filedto> attachmentdtos = msg.attachments.asparallel().select(attachment => downloadattachment(attachment, folder, msg, element, cancellationtokn)).where(x=>x!=null).tolist(); 

in case download list of attachments using asparallel, want able cancel part way. way done returning null when cancellationtoken invoked , filtering list nulls.

is there cleaner way this?


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

sql - Simple C# web application with a database -

c# - Abstract method in public abstract class implementing an internal interface doesn't compile? -