         if self.readyState != EventSourceState.Open {
             return
         }
-
-        self.receivedDataBuffer.appendData(data)
-        let eventStream = extractEventsFromBuffer()
-        self.parseEventStream(eventStream)
+        dispatch_async(dispatch_get_main_queue()) { 
+            self.receivedDataBuffer.appendData(data)
+            let eventStream = self.extractEventsFromBuffer()
+            self.parseEventStream(eventStream)
+        }
+
     }
 
     public func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveResponse response: NSURLResponse, completionHandler: ((NSURLSessionResponseDisposition) -> Void)) {


        if let errorBeforeSet = self.errorBeforeSetErrorCallBack {
            self.onErrorCallback!(errorBeforeSet)
            self.errorBeforeSetErrorCallBack = nil
        }
    }


        dispatch_async(dispatch_get_main_queue()) {
            if let errorCallback = self.onErrorCallback {
                errorCallback(error)
            }else {
                self.errorBeforeSetErrorCallBack = error
            }
        }
