[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Creating a Cancel Dialog for lengthy operations

Posted on 2000-01-05
4
Medium Priority
?
286 Views
Last Modified: 2010-04-10
I'm trying to create a dialog that alows to cancel a running report generation.
I've tried alreade to do this with both of the AfxTreads (work thread and UI tread) but always with the result, that the dialog only appears after the report is sucessfully created and displayed in the dialog.
The calling sequence was as follows in the InitInstance() method of the dialog:

//Create Working Dialog
CWorkThread* pWorkThread = (CWorkThread*) AfxBeginThread(RUNTIME_CLASS(CWorkThread));

//Create the desired report
readData(m_iReportNo);      

return TRUE;  // Here ends the init dialog

Does anyone know a better way to do this or maybe the mistake I did?

Thanks for your help
0
Comment
Question by:UandI
4 Comments
 
LVL 8

Expert Comment

by:Brain2000
ID: 2326258
The problem is, the dialog will not be displayed until the InitInstance() returns.  You return from InitInstance() after you have called the readData() function, therefore the report will always be created first.

Try using CreateThread(...) to call the readData(...) function.  That way, it will not block returning from the InitInstance() dialog.

Another possibility is calling the readData() function from the CWorkThread class.  I assume CWorkThread is what is controlling the behavior of the dialog box.
0
 
LVL 30

Accepted Solution

by:
SteveGTR earned 400 total points
ID: 2326447
Try http://www.microsoft.com/MSJ/0297/wicked/wicked0297.htm it's simple and easy.

Good Luck,
Steve
0
 
LVL 23

Expert Comment

by:chensu
ID: 2326800
0
 
LVL 2

Expert Comment

by:abdij
ID: 2328019
Hi,
  In the main application call the Dialog for Cancelling the report generation and then Read the records. Dont do it in the initinstance() of the dialog cancel dialog.

Try.
All the best,
Bye
Abdij
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

607 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