Fix " worklist item xxx,xxx,xx,not found for xx" Problem

if invoke the function that named DoK2Process() in the same page two times ,the error happen.

  private void DoK2Process(string ProcSN)
    {
        using (TransactionScope trancat = new TransactionScope())
        {
            SourceCode.K2ROM.WorklistItem worklistitem = K2RomWP.GetWorklistItem(ProcSN);
            //To do:worklistitem do something

            //finally
            worklistitem.Finish();
        }
    }

But if you debug to trace this funciton ,it can run successfully.
So First I guess that error occur by TransactionScope delay in disposing.

So I add codes to dispose it and then run it again, i failed again.

And I look through WorklistItem class,found it provide
Finish(bool Sync) function . So I Invoke this function (Finish(True)) in DoK2Process function and run it again.

Bingo,I am right.

there was also  info about this problem i found.

"As I understand, calling the worklistitem.Finish(true) means that the call is made synchronously - meaning the worklist item has been completed by the time the call returns. Otherwise, calling just worklistitem.Finish() means that the call returns before the worklist item is actually finished because the worklistitem is actually finished in a separate thread"

 

And You also Can  see the whole info  Here :http://k2underground.com/forums/thread/18564.aspx

Posted on 2008-05-16 14:33 {:) 阅读(...) 评论(...) 编辑 收藏