<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : AsyncParallelTaskCompletedArgs cannot be converted to AsyncEventArgs</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : AsyncParallelTaskCompletedArgs cannot be converted to AsyncEventArgs</description>
  <pubDate>Sat, 11 Apr 2026 11:13:59 -700</pubDate>
  <lastBuildDate>Wed, 29 Jul 2009 06:53:38 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=1388</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>AsyncParallelTaskCompletedArgs cannot be converted to AsyncEventArgs : This was a really slick workaround....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1388&amp;PID=5050#5050</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=308" rel="nofollow">skingaby</a><br /><strong>Subject:</strong> 1388<br /><strong>Posted:</strong> 29-Jul-2009 at 6:53am<br /><br />This was a really slick workaround.  It works like a charm.  I have even used this in the middle of a longer stack of serial tasks (i.e. calling InitializeCache and then doing some other things afterwards).  Very nice.  Thank you for your help!]]>
   </description>
   <pubDate>Wed, 29 Jul 2009 06:53:38 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1388&amp;PID=5050#5050</guid>
  </item> 
  <item>
   <title>AsyncParallelTaskCompletedArgs cannot be converted to AsyncEventArgs : The async actions in the AsyncSerialTask...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1388&amp;PID=5019#5019</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 1388<br /><strong>Posted:</strong> 23-Jul-2009 at 6:42pm<br /><br />The async actions in the AsyncSerialTask expect an AsyncCompletedCallback of AsyncEventArgs or a sub-type, and unfortunately the AsyncParallelTaskCompletedArgs aren't a sub-type of AsyncEventArgs.&nbsp; We'll look at fixing this. <DIV>&nbsp;</DIV><DIV>Meanwhile, you can still do what you need, but with a bit more work.&nbsp; Since you can't use AddAsyncAction&lt;AsyncParallelTaskCompletedArgs&gt; with the serial task, you need to insert a dummy action here to tie the results of the parallel task back to the serial task.&nbsp; There are probably more clever ways to do this, but here's one -</DIV><DIV>&nbsp;</DIV><DIV><table width="99%"><tr><td><pre class="BBcode"></DIV><DIV>&nbsp;&nbsp;&nbsp; public void TestLockedMonth() {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _em = new DomainModel.DomainModelEntityManager();</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var task1 = AsyncSerialTask.Create();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var task2 = task1.AddAsyncLogin(_em1, new LoginCredential(null, null, null));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var task3 = task2.AddAction(x =&gt; Assert.IsTrue(_em1.IsLoggedIn));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var task4 = task3.AddAction(x =&gt; Assert.IsTrue(_em1.IsConnected));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var task5 = task4.AddAsyncAction&lt;AsyncEventArgs&gt;((x, cb) =&gt; InitializeCacheAsync(cb, TestLockedMonthCallback));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EnqueueCallback(() =&gt; task5.Execute(null, args =&gt; TestLockedMonthCallback2(args)));<BR>&nbsp;&nbsp;&nbsp; }</DIV><DIV>&nbsp;&nbsp;&nbsp; // Take 2 args here - 1 the serial task callback, the other the parallel task completion action.<BR>&nbsp;&nbsp;&nbsp; public void InitializeCacheAsync(AsyncCompletedCallback&lt;AsyncEventArgs&gt; serialCB, Action&lt;AsyncParallelTaskCompletedArgs&gt; completionAction) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var task = AsyncParallelTask.Create();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; task.AddAsyncQuery(1, x =&gt; _defaultManager.AccountingMonths);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; task.AddAsyncQuery(2, x =&gt; _defaultManager.DealTypes);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Any object can be passed as input and available to the completion action.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; task.Execute(serialCB, completionAction);<BR>&nbsp;&nbsp;&nbsp; }</DIV><DIV>&nbsp;&nbsp;&nbsp; // Parallel task completion action<BR>&nbsp;&nbsp;&nbsp; public void TestLockedMonthCallback(AsyncParallelTaskCompletedArgs args) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // We passed this callback as input parm into the AsyncParallelTask<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var serialCB = args.ExecutionInput as AsyncCompletedCallback&lt;AsyncEventArgs&gt;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Build new args, taking advantage of userState input argument.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AsyncEventArgs newArgs = null;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (args.Ok) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // This is arbitrary - here we supply parallel task completion info ...<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newArgs = new AsyncEventArgs(args.CompletionMap);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Also arbitrary - if parallel task failed provide some info ...<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newArgs = new AsyncEventArgs(args.Errors&#091;0&#093;.Exception, false, args.Errors);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Now call the serial task's callback action.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; serialCB(newArgs);<BR>&nbsp;&nbsp;&nbsp; }</DIV><DIV>&nbsp;&nbsp;&nbsp; // Called when serial task completes.<BR>&nbsp;&nbsp;&nbsp; public void TestLockedMonthCallback2(AsyncSerialTaskCompletedArgs&lt;AsyncEventArgs&gt; args) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Result here is the result from the parallel task completion.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var result = args.Result;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var completionMap = result.UserState as Dictionary&lt;object, AsyncEventArgs&gt;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TestExit();<BR>&nbsp;&nbsp;&nbsp; }<BR></pre></td></tr></table></DIV>]]>
   </description>
   <pubDate>Thu, 23 Jul 2009 18:42:26 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1388&amp;PID=5019#5019</guid>
  </item> 
  <item>
   <title>AsyncParallelTaskCompletedArgs cannot be converted to AsyncEventArgs : I&amp;#039;ve created the following...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1388&amp;PID=5011#5011</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=308" rel="nofollow">skingaby</a><br /><strong>Subject:</strong> 1388<br /><strong>Posted:</strong> 23-Jul-2009 at 11:33am<br /><br />I've created the following unit test:<br /><br /><table width="99%"><tr><td><pre class="BBcode">&#091;TestMethod&#093;<br />&#091;Asynchronous&#093;<br />public void TestLockedMonth()<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;_em = new DomainModel.DomainModelEntityManager();<br />&nbsp;&nbsp;&nbsp;&nbsp;var task1 = AsyncSerialTask.Create();<br />&nbsp;&nbsp;&nbsp;&nbsp;var task2 = task1.AddAsyncLogin(_em, new LoginCredential(null, null, null));<br />&nbsp;&nbsp;&nbsp;&nbsp;var task3 = task2.AddAction(x =&gt; Assert.IsTrue(_em.IsLoggedIn));<br />&nbsp;&nbsp;&nbsp;&nbsp;var task4 = task3.AddAction(x =&gt; Assert.IsTrue(_em.IsConnected));<br />&nbsp;&nbsp;&nbsp;&nbsp;var task5 = task4.AddAsyncAction&lt;AsyncParallelTaskCompletedArgs&gt;((loginEventArgs, callback) =&gt; LocalEntityManager.InitializeCacheAsync(callback));<br />&nbsp;&nbsp;&nbsp;&nbsp;EnqueueCallback(() =&gt; task5.Execute(null, args =&gt; TestLockedMonthCallback(args)));<br />}</pre></td></tr></table><br /><br />The InitializeCacheAsync method looks like this:<br /><table width="99%"><tr><td><pre class="BBcode">public static void InitializeCacheAsync(Action&lt;AsyncParallelTaskCompletedArgs&gt; callback)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;var task = AsyncParallelTask.Create();<br />&nbsp;&nbsp;&nbsp;&nbsp;task.AddAsyncQuery(1, x =&gt; _defaultManager.AccountingMonths);<br />&nbsp;&nbsp;&nbsp;&nbsp;task.AddAsyncQuery(2, x =&gt; _defaultManager.DealTypes);<br />&nbsp;&nbsp;&nbsp;&nbsp;task.Execute(callback);<br />}</pre></td></tr></table><br /><br />This compiler error shows:<br /><font color=red>The type 'IdeaBlade.EntityModel.AsyncParallelTaskCompletedArgs' cannot be used as type parameter 'T2' in the generic type or method 'IdeaBlade.EntityModel.AsyncSerialTask&lt;T0,T1&gt;.AddAsyncAction&lt;T2&gt;(System.Action&lt;T1,IdeaBlade.EntityModel.AsyncCompletedCallback&lt;T2&gt;&gt;)'. There is no implicit reference conversion from 'IdeaBlade.EntityModel.AsyncParallelTaskCompletedArgs' to 'IdeaBlade.EntityModel.AsyncEventArgs'.</font><br /><br />Is something I can work around?  Thanks, Simon.]]>
   </description>
   <pubDate>Thu, 23 Jul 2009 11:33:47 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1388&amp;PID=5011#5011</guid>
  </item> 
 </channel>
</rss>