     return promise.future
 }
 
+func executionContextForCurrentContext() -> ExecutionContext {
+    return toContext(NSThread.isMainThread() ? Queue.main : Queue.global)
+}
+
 public let BrightFuturesErrorDomain = "nl.thomvis.BrightFutures"
 
 public enum ErrorCode: Int {

        }
        
        self.callbacks.removeAll()
    }
    
    private func executionContextForCurrentContext() -> ExecutionContext {
        return toContext(NSThread.isMainThread() ? Queue.main : Queue.global)
    }
}


        return p.future
    }

    public func andThen(context c: ExecutionContext = executionContextForCurrentContext(), callback: Result<T> -> ()) -> Future<T> {
        let p = Promise<T>()
        
        self.onComplete(context: c) { result in
