Click here to Skip to main content
14,878,186 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi All,

I need some help on my below scenario:

I have created a dialog based application in Visual Studio 2010 in MFC C++. My Main Dialog is Modal and I have a Menu that displays on Right Click on my Dialog.

In one of the Menu, I do some processing and display another Dialog which is modeless. During this processing, User should be able to:
1. Click on any other menu of Main Dialog.
2. If Close is hit on the Main Dialog, it should wait until this processing is completed and Close All once processing is completed.
3. Should be able to repeat same process n number of times (for eg. The 2nd Modeless dialog can be opened in more than 1 instance with different result as per processing and option chosen).

For this, I have tried to use Multithread where each of my 2nd Modeless dialog can be hooked up in a different thread & Main Dialog can also be kept alive with all its Menu accessible during this processing.

Problem: I am not able to determine if the thread exited correctly, destructor of my 2nd modeless dialog is not getting a breakpoint hit. The application closes with exitcode as 2 are my observations..

I want to learn more about MultiThreading and will this be the best solution or any other references are suggested?

Thank you in advance..

[edit]Urgency deleted - OriginalGriff[/edit]
Posted
Updated 25-Aug-15 4:21am
v2
Comments
OriginalGriff 25-Aug-15 10:21am
   
Urgency deleted: It may be urgent to you, but it isn't to us. All that your stressing the urgency does is to make us think you have left it too late, and want us to do it for you. This annoys some people, and can slow a response.
[no name] 25-Aug-15 10:30am
   
Sorry, But this was not my meaning for writing the keyword "Urgent". I have read a many articles and I wanted someone to guide, which is the best way to solve such scenario's so that I can think & learn. Its Ok, even if it takes time, but surely I need a answer. Its just my own learning curiosity.
Richard Deeming 25-Aug-15 12:22pm
   
That's an interesting comment.

In English, "urgent" means "requiring immediate attention". But if some source has mis-translated it, and given it a different meaning, that might explain why we see so many "urgent" questions here. :)

1 solution

It makes no sense. You don't need multithreading to enable the UI with more than one window, modal or not. However, you can and should use a separate thread for any long-running processing. Unfortunately, the Quick Questions & Answers format is not designed to teach the whole topic of threading; you can do it yourself using appropriate documentation.

—SA
   
Comments
[no name] 26-Aug-15 1:55am
   
Thank You for the reply. I agree to use Thread and have used the same concept. After processing, when my dialog is shown, its PreTranslateMessage method, is not getting invoked when I press keys like "Ctrl+A".

Can you give me a reference of a similar known scenario where long processing is executed in a separate thread and then shows a DialogBox (modeless) where this can be performed 'n' number of times while another is in process.
   
I have no idea what does it mean, "reference a scenario" or "known scenario". Execute some non-UI thread which sends a message to the UI thread with PostMessage or SendMessage.
—SA
[no name] 26-Aug-15 9:57am
   
Ok.. Thank You
Sergey Alexandrovich Kryukov 26-Aug-15 10:28am
   
You are welcome.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900