TPL Task Canceled - How Often to Check How to Wait

Answered TPL Task Canceled - How Often to Check How to Wait

  • Wednesday, March 21, 2012 9:17 PM
     
     

    I'm not sure if what follows are good ideas, but that's why I'm posting :-)

    I start my MasterProcess (mp) as: var taskProc = Task.Factory.StartNew(() => { MasterProcess(bContinue); }, TaskToken.Token);

    In mp..
    bWait = processNext(dLog, out dNext); // timespan by config file
    While (bWait == false & bContinue == true)
    QueueCheck() // checks log & checks out the next record to process
    if (emailAddress != null & bContinue == true)

    At this point I have a problem because if I have (and I do) an emailAddress then the log for that record is checked out to process, aborting will leave data hanging; Is there a way to remain in the inner loop & continue to process the record which may take 10 seconds (connecting to ConstantContact, getting a response & updating the CRM database & log) - Perhaps a way to set the TaskToken to cannot be cancelled?

    Before I do the next eval on bWait, I first check; if (TaskToken.IsCancellationRequested == true), if so, I then set bContinue = false and all is wright in the world.

    My worst fear is that during the send to CtCt or during the resulting database update the the application will be aborted.

    FYI, although there is a UI for my app it's a server side app that runs to synchronize the CRM with CtCt, so my hope is that since only admin will be starting or stopping it, they'll also be able to deal with any fallout.


    JeffP...

All Replies

  • Monday, March 26, 2012 8:36 AM
     
     

    Hi JeffPGMT,

    Since this thread is not related to WPF forum, I have moved it to Where is the forum for... forum to help you find an appropriate forum for your question.

    Best regards,


    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us

  • Saturday, March 31, 2012 3:46 AM
    Owner
     
     Answered

    Unfortunately we'll need more information about the technology you're using.

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Experience Program Manager (Blog, Twitter, Wiki)