    */
   public func startScanning() {
     if !session.isRunning {
-      session.startRunning()
+      sessionQueue.async {
+        self.session.startRunning()
+      }
     }
   }
 
   /// Stops scanning the codes.
   public func stopScanning() {
     if session.isRunning {
-      session.stopRunning()
+      sessionQueue.async {
+        self.session.stopRunning()
+      }
     }
   }
 


      session.commitConfiguration()
    }
    return session.inputs.first as? AVCaptureDeviceInput
  }



  // MARK: - AVCaptureMetadataOutputObjects Delegate Methods

  public func metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection) {
    for current in metadataObjects {
      if let _readableCodeObject = current as? AVMetadataMachineReadableCodeObject {
        if _readableCodeObject.stringValue != nil {
