                 try await(task)
                 
                 if let didFinishWithValueClosure = self.didFinishWithValueClosure {
-                    self.didFinishWithValueClosure = nil
-                    
                     DispatchQueue.main.async {
                         didFinishWithValueClosure(task.value!)
+                        self.didFinishWithValueClosure = nil
                     }
                 }
             }
             catch let error {
                 if error.isUserCancelled {
                     if let didCancelClosure = self.didCancelClosure {
-                        self.didCancelClosure = nil
-                        
                         DispatchQueue.main.async {
                             didCancelClosure()
+                            self.didCancelClosure = nil
                         }
                     }
                 }
                 else {
                     if let didFinishWithErrorClosure = self.didFinishWithErrorClosure {
-                        self.didFinishWithErrorClosure = nil
-                        
                         DispatchQueue.main.async {
                             didFinishWithErrorClosure(error)
+                            self.didFinishWithErrorClosure = nil
                         }
                     }
                 }

            await(task)
            
            if let didFinishWithValueClosure = self.didFinishWithValueClosure {
                self.didFinishWithValueClosure = nil
                
                DispatchQueue.main.async {
                    didFinishWithValueClosure(task.value!)
                }
            }
        }

        queue.addOperation {
            defer {
                if let didFinishClosure = self.didFinishClosure {
                    DispatchQueue.main.async {
                        didFinishClosure()
                        self.didFinishClosure = nil
                    }
                }
            }
