<?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 : AsyncSerialTask</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : AsyncSerialTask</description>
  <pubDate>Fri, 10 Apr 2026 21:36:57 -700</pubDate>
  <lastBuildDate>Wed, 30 Sep 2009 14:22:21 -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=1501</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>AsyncSerialTask : The syntax of the AsyncSerialTask...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1501&amp;PID=5546#5546</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> 1501<br /><strong>Posted:</strong> 30-Sep-2009 at 2:22pm<br /><br />The syntax of the AsyncSerialTask is pretty abstruse.&nbsp; Here's one way to implement this - <DIV><table width="99%"><tr><td><pre class="BBcode"></DIV><DIV>&nbsp;private void LoadData(string userID) {<BR>&nbsp;&nbsp; //Guid myToken = Guid.NewGuid();<BR>&nbsp;&nbsp; //object&#091;&#093; param = {userID};</DIV><DIV>&nbsp;&nbsp; AsyncSerialTask.Create&lt;string&gt;()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .AddAsyncInvokeServerMethod&lt;object, object, InvokeServerMethodEventArgs&gt;(m_mgr, <BR>&nbsp;&nbsp;"C2NetDomainModel.EntCustomer,C2NetDomainModel", "GetCustomerIDs",<BR>&nbsp;&nbsp; inputArg=&gt; new object&#091;&#093; {inputArg})<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .AddAsyncQuery(args =&gt; GotCustomerIds(args))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;.AddExceptionHandler(exArgs =&gt; WriteMessage(exArgs.Exception.Message))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Execute(userID, (completionArgs) =&gt; GotCustomers(completionArgs.Result));<BR>&nbsp; }</DIV><DIV>&nbsp; public IEntityQuery&lt;EntCustomer&gt; GotCustomerIDs( InvokeServerMethodEventArgs args )<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; int&#091;&#093; customerIDs = ((C2NetDomainModel.IntIDs)(args.Result)).p_ids;<BR>&nbsp;&nbsp;&nbsp; var customerQ = m_mgr.EntCustomerSet<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .OrderBy( c =&gt; c.p_name )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .WhereIn( c =&gt; c.p_customerID , customerIDs );</DIV><DIV>&nbsp;&nbsp;&nbsp; return customerQ;<BR>&nbsp; }</DIV><DIV>&nbsp; private void GotCustomers(EntityFetchedEventArgs&lt;EntCustomer&gt; args)<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; foreach( EntCustomer c in args.Result ) <BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp; _customers.Add(c); <BR>&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp; // Set CurrentItem to first Customer so form will flesh out <BR>&nbsp;&nbsp;&nbsp; if (_customers.Count &gt; 0) {<BR>&nbsp;&nbsp;&nbsp;&nbsp; _customerDataForm.CurrentItem = _customers&#091;0&#093;;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; ReportFetchCount(args.Result, "Customer");<BR>&nbsp; }<BR></pre></td></tr></table></DIV><DIV>&nbsp;</DIV><DIV>Things to note - </DIV><DIV>1) When you create the task you can specify the type of the input argument, in this case a string.</DIV><DIV>2) A few of the overloads for AddAsyncInvokeServerMethod take a lambda as a final argument.&nbsp; This is what we're using here: it takes a string (the input to the task) and returns an object array containing that string.</DIV><DIV>3) AddAsyncInvokeServerMethod defines T0, T1 and T2 and I admit I don't know why there are 3 type arguments instead&nbsp;of two.&nbsp; But anyway, T0 and T1 should be the input type (and can be 'object' if no input is provided, and T2 is 'InvokeServerMethodArgs'.&nbsp;</DIV><DIV>4) Exceptions are handled a bit differently with an AsyncSerialTask, and you should add an exception handler to the task to trap any errors.</DIV><DIV>5) GotCustomerIDs takes the InvokeServerMethodEventArgs and builds a query, which it then returns as the async query to be run next.</DIV><DIV>6) task.Execute accepts an input argument, in this case the string userID.&nbsp; This is passed to the first action in the task.</DIV><DIV>7) At completion, the results of the last action are available in the Result property.&nbsp; This is passed to the GotCustomers method.</DIV>]]>
   </description>
   <pubDate>Wed, 30 Sep 2009 14:22:21 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1501&amp;PID=5546#5546</guid>
  </item> 
  <item>
   <title>AsyncSerialTask : Hi, I&amp;#039;m trying to use AsyncSerialTask...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1501&amp;PID=5539#5539</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=508" rel="nofollow">tj62</a><br /><strong>Subject:</strong> 1501<br /><strong>Posted:</strong> 30-Sep-2009 at 7:53am<br /><br /><P>Hi,</P><DIV>I'm trying to use AsyncSerialTask with the&nbsp; <FONT size=2>AddAsyncInvokeServerMethod(). However the declaration of this metod that the Intellisens shows looks like chinees to me. I could not find any DevForce documentation for this nor any samples. The documentation includes one sample for AsyncSerialTask with limited explanation...hard to understand.</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>Can anyone explain for me how to use AssyncSerialTask.Create().AddAsyncInvokServerMethod()</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>Here is the serial sequence I'm trying to move to AsyncSerialTask:</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=1>&nbsp;&nbsp;private void LoadData(string userID) {<BR>&nbsp;&nbsp;&nbsp;Guid myToken = Guid.NewGuid();<BR>&nbsp;&nbsp;&nbsp;object&#091;&#093; param = {userID};<BR>&nbsp;&nbsp;&nbsp;m_mgr.InvokeServerMethodAsync("C2NetDomainModel.EntCustomer,C2NetDomainModel",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "GetCustomerIDs",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GotCustomerIDs, myToken, userID);</FONT></DIV><DIV><FONT size=1>&nbsp;&nbsp;}</FONT></DIV><DIV><FONT size=1>&nbsp;&nbsp;public void GotCustomerIDs( InvokeServerMethodEventArgs args )<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;if( args.Error != null )<BR>&nbsp;&nbsp;&nbsp;&nbsp;WriteMessage( args.Error.Message );<BR>&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;int&#091;&#093; customerIDs = ((C2NetDomainModel.IntIDs)(args.Result)).p_ids;<BR>&nbsp;&nbsp;&nbsp;&nbsp;var customerQ = m_mgr.EntCustomerSet<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .OrderBy( c =&gt; c.p_name )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .WhereIn( c =&gt; c.p_customerID , customerIDs );</FONT></DIV><DIV><FONT size=1>&nbsp;&nbsp;&nbsp;&nbsp;m_mgr.ExecuteQueryAsync( (IEntityQuery&lt;EntCustomer&gt;)customerQ, GotCustomers , null );<BR>&nbsp;&nbsp;&nbsp;}</FONT></DIV><DIV><FONT size=1>&nbsp;&nbsp;}</FONT></DIV><DIV><FONT size=1>&nbsp;&nbsp;private void GotCustomers(EntityFetchedEventArgs args)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;if (args.Error != null) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;WriteMessage(args.Error.Message);<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;else {<BR>&nbsp;&nbsp;&nbsp;&nbsp;//foreach( EntCustomer c in (System.Linq.IQueryable)args.Result ) <BR>&nbsp;&nbsp;&nbsp;&nbsp;foreach( EntCustomer c in (IEnumerable&lt;EntCustomer&gt;)args.Result ) <BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_customers.Add(c); <BR>&nbsp;&nbsp;&nbsp;&nbsp;} <BR>&nbsp;&nbsp;&nbsp;&nbsp;// Set CurrentItem to first&nbsp;Customer so form will flesh out <BR>&nbsp;&nbsp;&nbsp;&nbsp;if (_customers.Count &gt; 0) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_customerDataForm.CurrentItem = _customers&#091;0&#093;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;ReportFetchCount(args.Result, "Customer");<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}</FONT></DIV><FONT size=2><DIV><BR>Can anyone tell me how to change this to a AsyncSerialTask?</DIV><DIV></FONT>&nbsp;</DIV>]]>
   </description>
   <pubDate>Wed, 30 Sep 2009 07:53:53 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1501&amp;PID=5539#5539</guid>
  </item> 
 </channel>
</rss>