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
Post a Comment