Re: Waiting to thread exit
- From: "Sebastian Warmuz" <sebastian@xxxxxxxxxxx>
- Date: Sun, 9 Sep 2007 13:29:10 +0100
Thx Scott And Joseph.
Sorry for my stupid questions but I already started to learn threads. I made
everythign like You said and now everything works fine. But I have only one
small problem....
In the method I am creating a therad I have to obtain that thread is
finished. This thread will make a backup of some files and after job is done
it will continue to lauch application
void CMyApp::OnInitInstance()
{
// 1. init etc,
// 2. make backup in thread displaying progress
// 3. if backup made do the res
}
But the problem is that point 3 is started when backup thread is not yet
finished.... How o resolve it ?
Regards
Uzytkownik "Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> napisal w
wiadomosci news:uU$zW6l8HHA.484@xxxxxxxxxxxxxxxxxxxxxxx
"Sebastian Warmuz" <sebastian@xxxxxxxxxxx> wrote in message
news:O2KuoVk8HHA.396@xxxxxxxxxxxxxxxxxxxxxxx
Hi I am copyying file in a thread, meanwhile I am displaying a disloag
with progress bar, the problem is that message box is displayed before
copying is finished. Can anyone help me ??
Your code started the copying thread, then immediately displayed the "Copy
Finished" message box. That is why the message box is displayed. Don't
call the message box in the same function that starts the thread. Just
return to MFC after you start the thread so the GUI can process messages
while the copy runs.
Add a message handler in the main GUI :
ON_MESSAGE(WM_USER_THREAD_COPY_FINISHED, OnCopyFinished)
and display the message box in this message hander. For some reason you
posted this message to the copy thread, but you should post it to the GUI
main window and create all of your GUI displays in the main thread.
.
- Follow-Ups:
- Re: Waiting to thread exit
- From: Joseph M . Newcomer
- Re: Waiting to thread exit
- From: Scott McPhillips [MVP]
- Re: Waiting to thread exit
- References:
- Waiting to thread exit
- From: Sebastian Warmuz
- Re: Waiting to thread exit
- From: Scott McPhillips [MVP]
- Waiting to thread exit
- Prev by Date: Re: Code Page problem in SetWindowText
- Next by Date: Connection String for SQL Server ???
- Previous by thread: Re: Waiting to thread exit
- Next by thread: Re: Waiting to thread exit
- Index(es):
Relevant Pages
|