int processCount = await Task.Run<int>(() =>
Should be
int processCount = await Task.Run<int>(async () =>
Remember that a lambda is just shorthand for defining a method. So, your outer method is async
, but in this case you're trying to use await
within a lambda (which is a different method than your outer method). So your lambda must be marked async
as well.