[blam] ChannelGroup: don't use Parallel
- From: Carlos Martín Nieto <cmartin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [blam] ChannelGroup: don't use Parallel
- Date: Sat, 15 Jun 2013 20:48:29 +0000 (UTC)
commit 2e06c67e54b060835c168931bb5bf482f4409fcc
Author: Carlos Martín Nieto <cmn dwim me>
Date: Sat Jun 15 21:14:07 2013 +0200
ChannelGroup: don't use Parallel
That waits synchronously for all the threads to return. Use
Thread.WhenAll() which is awaitable.
src/ChannelGroup.cs | 13 ++++---------
1 files changed, 4 insertions(+), 9 deletions(-)
---
diff --git a/src/ChannelGroup.cs b/src/ChannelGroup.cs
index cafb66e..b6f4486 100644
--- a/src/ChannelGroup.cs
+++ b/src/ChannelGroup.cs
@@ -160,16 +160,11 @@ namespace Imendio.Blam
return null;
}
- public delegate bool RefreshDelegate();
- public bool Refresh()
+ public async Task<bool> RefreshAsync()
{
- Parallel.ForEach(Channels.Cast<Channel>(), c => c.RefreshAsync());
- return true; // Whatever
- }
-
- public Task<bool> RefreshAsync()
- {
- return Task<bool>.Factory.StartNew(Refresh);
+ var tasks = Channels.Cast<Channel>().Select(c => c.RefreshAsync());
+ // FIXME: The continuation is a horrible hack to fit the interface
+ return await Task.WhenAll(tasks).ContinueWith(task => true);
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]