title: How to use results from different isolates in the main isolate?
body: <p>I'm really new to Dart and also to programming. I'm trying to develop a a <strong>command-line</strong> program in Dart using isolates. My intention is to compare it's performance againt the same program, but written in Java with threads.</p>
  
  <p>The Dart program looks like this so far:</p>
  
  <ol>
  <li><p>main.dart</p>
  
  <pre><code>import "dart:async";
  import "dart:isolate";
  
  main() {    
      var rPort1 = new ReceivePort();
      var rPort2 = new ReceivePort();
  
      var p1 = 0;
      rPort1.listen((partial) {
          print("p1 ${partial}");
          p1 = partial;
          rPort1.close();
      });
      var p2 = 0;
      rPort2.listen((partial) {
         print("p2 ${partial}");
         p2 = partial;
         rPort2.close();
      });
  
      Isolate.spawnUri(new Uri.file("MyIsolate.dart"), [arg0, ...], rPort1.sendPort);
      Isolate.spawnUri(new Uri.file("MyIsolate.dart"), [arg0, ...], rPort2.sendPort);
  
      var p3 = p1 + p2;
      print("p3 ${p3}");
  }
  </code></pre></li>
  <li><p>myIsolate.dart</p>
  
  <pre><code>import "dart:async";
  import "dart:isolate";
  
  main(args, SendPort port) {
      var partial = 0;
      // ... do stuff ...
      // args are used and partial is updated
      port.send(partial);
  }
  </code></pre></li>
  </ol>
  
  <p>The output looks like this:</p>
  
  <pre><code>p3 0
  p1 -0.1168096561671553
  p2 0.023709338284264223
  </code></pre>
  
  <p>As you can see the return values of each <strong>isolate</strong> comes after the <strong>main isolate</strong> has finished it's execution. What I want is to use the result of the isolates to further calculation in the main.</p>
  
  <p>I don't know what I'm missing. I'm sure is something very stupid, but I cannot move forward on this problem. In Java is simple to get the result value of each thread, but in Dart I can't figure how to do this in isolates.</p>
  
  <p>Any ideas?</p>