Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

AbortProc question...

Posted on 1998-01-22
5
240 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 49
Whole sheet autoscrub still needed 19 51
Prevent this page from creating additional dialogs. 3 614
EvenOdd challenge 10 126
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

860 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