Solved

AbortProc question...

Posted on 1998-01-22
5
232 Views
Last Modified: 2013-11-20
How can i implement an "AbortProc" callback function to a very long process? code avaliable?

Thanx in advance.
Mário Guedes
0
Comment
Question by:mguedes
  • 3
  • 2
5 Comments
 

Author Comment

by:mguedes
ID: 1314544
Edited text of question
0
 
LVL 2

Expert Comment

by:anichini
ID: 1314545
i dunno if this is what you want, but it'll work.

class Callback
{
public:
  virtual bool operator()(int progress, int total)=0;
};

class VeryLongProcess
{
public:
    VeryLongProcess(Callback *pCB) : m_pCB(pCB {}

    void doit();
private:
    Callback *m_pCB;
};


void VeryLongProcess::doit()
{
    for(int i = 0; i < VLP_ITERATIONS; i++)
    {
        if(!(i&0x7f)) // every 128 iterations
        {
          if(!(*m_pCB)(i, VLP_ITERATIONS))
          {
            break; // abort
          }
        }
        // ... do actual work here
    }

    if (i != VLP_ITERATIONS)
    {
      // we aborted, do abort cleanup
    }
}

0
 

Author Comment

by:mguedes
ID: 1314546
thanx anichini, this help´s me.
0
 
LVL 2

Accepted Solution

by:
anichini earned 10 total points
ID: 1314547
the answer is above.

0
 

Author Comment

by:mguedes
ID: 1314548
Thanx again, anichini
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now