Created
June 13, 2014 12:49
-
-
Save AndersNS/b66b69929c6e7df754c9 to your computer and use it in GitHub Desktop.
Cancelationtoken method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async Task<int> ProcessObjectsAsync(List<SomeObjects> objectList, IProgress<int> progress,CancellationToken ct) | |
{ | |
int processCount = await Task.Run<int>(() => | |
{ | |
foreach (var someObject in objectList) | |
{ | |
ct.ThrowIfCancellationRequested(); | |
// process next thing | |
} | |
}, ct); | |
return processCount; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment