Permalink
Browse files

example for call with futures

  • Loading branch information...
1 parent 5c86d3a commit e00f2adacd9904c2df34f9adb26a07f2c2516c52 @grobmeier committed Apr 27, 2012
Showing with 37 additions and 0 deletions.
  1. +37 −0 easyisolate/CallIsolate.dart
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#import('dart:isolate');
+
+process() {
+ print("Hello");
+ port.receive((var message, SendPort replyTo) {
+ print ("Process: ${message}");
+ replyTo.send("done");
+ port.close();
+ });
+}
+
+main() {
+ print ("main starts");
+ SendPort send = spawnFunction(process);
+ send.call("start").then((var message) {
+ print ("Reply: ${message}");
+ });
+ print ("main ended");
+}

0 comments on commit e00f2ad

Please sign in to comment.