anchor.diff:  
       let doc = new FSharpParsedDocument(fileName)
       doc.Flags <- doc.Flags ||| ParsedDocumentFlags.NonSerializable
  -       
  -    Debug.WriteLine("[Thread {0}]: TriggerParse file {1}, hash {2}", System.Threading.Thread.CurrentThread.ManagedThreadId, fileName, hash fileContent)
  -    // Trigger a parse/typecheck in the background. After the parse/typecheck is completed, request another parse to report the errors.
  -    //
  -    // Trigger parsing in the language service 
  -    let filePathOpt = 
  -        // TriggerParse will work only for full paths
  -        if IO.Path.IsPathRooted(fileName) then 
  -            Some(fileName)
  -        else 
  -           let doc = IdeApp.Workbench.ActiveDocument 
  -           if doc <> null then 
  -               let file = doc.FileName.ToString()
  -               if file = "" then None else Some file
  -           else None
  -    
  -    let callTriggerParseAndWaitForResults(fileName, filePath, fileContent, files, args, framework) =
  -        use wh = new Threading.ManualResetEvent(false)
  -        let errs = ref Array.empty
  -        MDLanguageService.Instance.TriggerParse(fileName, filePath, fileContent, files, args, framework,
  -            (fun (_,errors) -> errs := errors
  -                               wh.Set() |> ignore ))
  -        wh.WaitOne(400) |> ignore
  -        !errs
  -                 
  -    match filePathOpt with 
  -    | None -> doc :> _
  -    | Some filePath -> 
  -      let config = IdeApp.Workspace.ActiveConfiguration
  -      if config = null then doc :> _ else 
  -        let files = CompilerArguments.getSourceFiles(proj.Items) |> Array.ofList
  -        let args = CompilerArguments.getArgumentsFromProject(proj, config)
  -        let framework = CompilerArguments.getTargetFramework( (proj :?> MonoDevelop.Projects.DotNetProject).TargetFramework.Id)
  +
  +    // Check if this is a reparse.
  +    match activeRequests.TryGetValue(fileName) with 
  +    | true, content when content = fileContent ->
  +        activeRequests.Remove(fileName) |> ignore
  +
  +    | _ ->
     
  -        let errors = callTriggerParseAndWaitForResults(proj.FileName.ToString(), filePath, fileContent, files, args, framework)
  -        //add the errors to the doc
  -        for er in makeErrors errors do
  -            doc.Errors.Add(er) 
  -  
  -        let typedParsedResult = MDLanguageService.Instance.GetTypedParseResult(proj.FileName.ToString(), filePath, fileContent, files, args, true, 400, framework)
  -  
  +      Debug.WriteLine("[Thread {0}]: TriggerParse file {1}, hash {2}", System.Threading.Thread.CurrentThread.ManagedThreadId, fileName, hash fileContent)
  +      // Trigger a parse/typecheck in the background. After the parse/typecheck is completed, request another parse to report the errors.
  +      //
  +      // Trigger parsing in the language service 
  +      let filePathOpt = 
  +          // TriggerParse will work only for full paths
  +          if IO.Path.IsPathRooted(fileName) then 
  +              Some(fileName)
  +          else 
  +             let doc = IdeApp.Workbench.ActiveDocument 
  +             if doc <> null then 
  +                 let file = doc.FileName.ToString()
  +                 if file = "" then None else Some file
  +             else None
  +
  +      match filePathOpt with 
  +      | None -> ()
  +      | Some filePath -> 
  +        let config = IdeApp.Workspace.ActiveConfiguration
  +        if config <> null then 
  +          // Keep a record that we have an inflight check of this going on
  +          activeRequests.[fileName] <- fileContent
  +          let files = CompilerArguments.getSourceFiles(proj.Items) |> Array.ofList
  +          let args = CompilerArguments.getArgumentsFromProject(proj, config)
  +          let framework = CompilerArguments.getTargetFramework( (proj :?> MonoDevelop.Projects.DotNetProject).TargetFramework.Id)
  +
  +          MDLanguageService.Instance.TriggerParse(proj.FileName.ToString(), filePath, fileContent, files, args, framework,
  +            (fun (_,errors) ->
  +                DispatchService.GuiDispatch( fun () ->
  +                    Debug.WriteLine("[Thread {0}]: Callback after parsing, file {1}, hash {2}", System.Threading.Thread.CurrentThread.ManagedThreadId, fileName, hash fileContent)
  +
  +                    // Keep the result until we reparse
  +                    activeResults.[fileName] <- makeErrors errors
  +                    typedParsedResult <- MDLanguageService.Instance.GetTypedParseResult(proj.FileName.ToString(), filePath, fileContent, files, args, true, 400, framework)
  +                    // Schedule a reparse to actually update the errors, checking first if this is still the active document
  +                    try 
  +                       let doc = IdeApp.Workbench.ActiveDocument
  +                       if doc <> null && doc.FileName.FullPath.ToString() = fileName then 
  +                           Debug.WriteLine("[Thread {0}]: Parsing: Requesting re-parse of file {1}, hash {2}",System.Threading.Thread.CurrentThread.ManagedThreadId,fileName, hash fileContent)
  +                           doc.ReparseDocument()
  +                    with _ -> ())))
  +
  +    if activeResults.ContainsKey(fileName) then
  +        for er in activeResults.[fileName] do 
  +            doc.Errors.Add(er)  
  +
  +        //Set code folding regions
           //GetNavigationItems may throw in some situations
           try
             let regions =
  
positive.code:   inherit TypeSystemParser()
    do Debug.WriteLine("Parsing: Creating FSharpParser")
          
    /// Format errors for the given line (if there are multiple, we collapse them into a single one)
    let formatError (error:ErrorInfo) =
        // Single error for this line
        let typ = if error.Severity = Severity.Error then ErrorType.Error
                  else ErrorType.Warning
        Error(typ, error.Message, DomRegion(error.StartLine + 1, error.StartColumn + 1, error.EndLine + 1, error.EndColumn + 1))
    
    /// To be called from the language service mailbox processor (on a 
    /// GUI thread!) when new errors are reported for the specified file
  
negative.code:                   for next in toplevel.Nested do yield processDecl next}
            doc.Add(regions)
          with _ -> Debug.Assert(false, "couldn't update navigation items, ignoring")  
          
          //also store the AST of active results if applicable                
          if storeAst then
              doc.Ast <- typedParsedResult
      
      doc.LastWriteTimeUtc <- (try File.GetLastWriteTimeUtc (fileName) with _ -> DateTime.UtcNow) 
      doc :> ParsedDocument
  