This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Resource<A> { | |
let pathComponent: String | |
let parse: AnyObject -> A? | |
} | |
extension Resource { | |
func loadAsynchronous(callback: A? -> ()) { | |
let session = NSURLSession.sharedSession() | |
let resourceURL = webserviceURL.URLByAppendingPathComponent(pathComponent) | |
session.dataTaskWithURL(resourceURL) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var testRepo = new TestRepo(); | |
//var start = DateTime.Now; | |
var t1 = testRepo.Task1(); | |
var t2 = testRepo.Task2(); | |
int[] r = await Task.WhenAll(t1, t2); | |
//var end = (DateTime.Now - start).Seconds; | |
return new int[] { r[0], r[1] }; | |
/***************************/ | |
public class TestRepo |