title: Vala yield not returning
body: <p>I'm having trouble writing an async function in Vala.<br />
  I understand that the function's callback has to get registered somewhere in order for execution to continue after the yield statements, so I add it to the GLib mainloop to be called periodically using <code>Idle.add</code>. Here is my dummy code:</p>
  <pre><code>async void loop_func()
  {
      var id = Idle.add(loop_func.callback);
      message(&quot;Added idle %u&quot;,id);
  
      yield;
      message(&quot;yielded successfully 1&quot;);
  
      yield;
      message(&quot;yielded successfully 2&quot;);
  
      for (var i = 0; i &lt; 20; i++)
      {
          message(&quot;%d&quot;,i);
          yield;
      }
  
      message(&quot;finished&quot;);
  }
  
  int main()
  {
      var loop = new GLib.MainLoop();
      loop_func.begin(() =&gt; {loop.quit();});
      loop.run();
      return 0;
  }
  </code></pre>
  <p>Despite this, the code after the 2nd yield statement never gets executed.
  This can be seen from the output:</p>
  <pre><code>$ ./async   
  ** Message: 20:07:24.932: async.vala:4: Added idle 1
  ** Message: 20:07:24.932: async.vala:7: yielded successfully 1
  </code></pre>
  <p>And then it hangs.<br />
  What am I missing here?</p>