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 - Extract Text from HTTP referer -

Receive udp packets in android gstreamer -

authentication - ASP.NET Core 1.0. Bearer Token, cannot access custom claims -