     @IBOutlet weak var msgTextField: NSTextField!
     @IBOutlet weak var chatTableView: NSTableView!
 
+    private let dispatchQueue = DispatchQueue(label: "hubsample.queue.dispatcheueuq")
+
     var chatHubConnection: HubConnection?
     var chatHubConnectionDelegate: ChatHubConnectionDelegate?
     var messages: [String] = []

    }

    func numberOfRows(in tableView: NSTableView) -> Int {
        return messages.count
    }

    func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {

        chatHubConnection = HubConnection(url: URL(string:"http://localhost:5000/chat")!, query: "")
        chatHubConnection!.delegate = chatHubConnectionDelegate
        chatHubConnection!.on(method: "NewMessage", callback: {args in
            self.dispatchQueue.sync {
                self.messages.append("\(args[0]!): \(args[1]!)")
            }
            self.appendMessage()

        })
