<?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 : Coroutine Question</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Coroutine Question</description>
  <pubDate>Sat, 11 Apr 2026 22:16:57 -700</pubDate>
  <lastBuildDate>Fri, 03 Dec 2010 15:17:19 -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=2347</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>Coroutine Question : The serial Coroutine allows you...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2347&amp;PID=9307#9307</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> 2347<br /><strong>Posted:</strong> 03-Dec-2010 at 3:17pm<br /><br />The serial Coroutine allows you to batch up async actions, but you can certainly intersperse synchronous logic and function calls within the iterator block.&nbsp;&nbsp; In what you're showing here CalculateFormula is a synchronous call, so you can call it within your iterator block.&nbsp; In this case "B" should also be doing something async, otherwise why bother with the Coroutine. <DIV>&nbsp;</DIV><DIV>You only need to use yield return when "yielding" due to an async operation.&nbsp; When you start an async operation you yield, and execution of the block resumes when the operation completes.&nbsp; A synchronous call does not require a yield.</DIV><DIV>&nbsp;</DIV><DIV>Also, the (optional) Coroutine.Return() result which you can return from an iterator block is not truly the same thing as the INotifyCompleted object which you yield return&nbsp;when awaiting the completion of the async operation.&nbsp; The Return(x) is just a handy way to return a result back to the caller,&nbsp;it's returned to the Coroutine completion handler in the Result property of the event args.&nbsp; So here, you could setup your call like this:</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;&nbsp; var op = Coroutine.Start(B);</DIV><DIV>&nbsp;&nbsp;&nbsp; op.Completed += (s,e) =&gt; {</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var result = e.Result;</DIV><DIV>&nbsp;&nbsp;&nbsp; }</DIV><DIV>&nbsp;</DIV><DIV>or this:</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;&nbsp; Coroutine.Start(B, op =&gt; {</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var result = op.Result;</DIV><DIV>&nbsp;&nbsp;&nbsp;});</DIV><DIV>&nbsp;</DIV><span style="font-size:10px"><br /><br />Edited by kimj - 03-Dec-2010 at 3:23pm</span>]]>
   </description>
   <pubDate>Fri, 03 Dec 2010 15:17:19 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2347&amp;PID=9307#9307</guid>
  </item> 
  <item>
   <title>Coroutine Question : I have a method which has my coroutine.start...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2347&amp;PID=9305#9305</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=202" rel="nofollow">BillG</a><br /><strong>Subject:</strong> 2347<br /><strong>Posted:</strong> 03-Dec-2010 at 1:53pm<br /><br /><P>I have a method which has my coroutine.start call in it. It calls the iterator routine. If the iterator routine calls another method is that new method automatically part of the coroutine or do I have to do another coroutine.start and basically have nested coroutines.</P><DIV>&nbsp;</DIV><DIV>public&nbsp;void&nbsp;A()</DIV><DIV>{</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var x = Coroutine.Start(B());</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>}</DIV><DIV>&nbsp;</DIV><DIV>public&nbsp;IEnumerable&lt;INotifyCompleted&gt;&nbsp;B()</DIV><DIV>{</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; double a, b;</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var y = AddFunction(a, b);</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yield return Coroutine.Return(y);</DIV><DIV>}</DIV><DIV>&nbsp;</DIV><DIV><FONT color=#ff0000>public double CalculateFormula(double a, double b)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // is this part of the coroutine? Do I have to do a yield return?</FONT></DIV><DIV><FONT color=#ff0000>{</FONT></DIV><DIV><FONT color=#ff0000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return a + b;</FONT></DIV><DIV><FONT color=#ff0000>}</FONT></DIV>]]>
   </description>
   <pubDate>Fri, 03 Dec 2010 13:53:06 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2347&amp;PID=9305#9305</guid>
  </item> 
 </channel>
</rss>