anchor.diff:          x.Terminate()
           x.SelfClose()
           // if waiting for event, set it
  -        // make sure we exit Process at least once after setting "IsTerminated" to true
  +        // make sure we exit Process at least once after setting "IsTerminated" to true, otherwise ProcWaitHandle may change
           let oldCount = procCount
           while (x.InProcessing && oldCount = procCount) do
               Thread.Sleep(10)
  
positive.code:                     (eventProc, false)
                  else if (isClosed()) then
                      Logger.LogF( LogLevel.MildVerbose, (fun _ -> sprintf "ThreadPool Function Work item %A terminates" (infoFunc(tpKey))))
                      closeAction()
                      // no more running on thread pool
                      SharedComponentState.Remove(x.CompBase.ComponentId, x.CompBase.SharedStateObj) |> ignore
                      x.ProcWaitHandle <- null
                      x.InProcessing <- false
                      (null, true)
                  else
                      x.ProcWaitHandle <- eventDQ
  
negative.code:             isTerminated <- true
              let spinWait = new SpinWait()
              let oldCnt = x.ProcCount
              // wait to prevent double release call for ReleaseItem on current item
              while (x.InProcessing && oldCnt=x.ProcCount) do
                  // if x.ProcCount has increased, then even if InProcessing, then Process has seen "isTerminated=true" condition
                  spinWait.SpinOnce()
  