Re: Batch file and MFC (Properly Terminating Application)
- From: "Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp>
- Date: Tue, 06 Feb 2007 12:16:09 -0500
one-trick-pony wrote:
I am having some difficulty, when instruction, delete myWorkerThread,
is executed-my application crashes and Send Error Report to Microsoft
window appears. When I comment out the line, I don't get that
error.
I have a few questions regarding slowing down application for user.
For example, I would like to give users a few seconds to choose
between action A or action B if user doesnt choose anything a default
action is made by application. I relied on Sleep function so far to
accomplish this. I would like to stop using sleep and implement the
desired behavior. Also, same goes for showing a splash screen. I want
to suspend/slow down for maybe a couple of seconds so users see a
splash screen. Usually, splash screens are used for decoy to quickly
start crunching application code. Furthermore, I like to be able to
suspend my application at times. Again, I relied on sleep so far to
implement suspend behavior.
You need to set the CWinThread's m_bAutoDelete to FALSE (before it executes!) to be sure the object will still exist when you delete it. Like this:
// Start thread with auto delete off
pThread = AfxBeginThread(ThreadProc, pParam,
THREAD_PRIORITY_NORMAL, 0,
CREATE_SUSPENDED);
pThread->m_bAutoDelete = FALSE;
pThread->ResumeThread();
All of your time delay questions are answered with SetTimer and a message handler for WM_TIMER. You set the timer interval, then you get a WM_TIMER message every interval.
> Furthermore, I like to be able to
> suspend my application at times. Again, I relied on sleep so far to
> implement suspend behavior.
Your application should return to MFC whenever you complete handling a message. MFC suspends it until a new message arrives. So maybe it already does what you want. What are you trying to accomplish?
--
Scott McPhillips [VC++ MVP]
.
- Follow-Ups:
- Re: Batch file and MFC (Properly Terminating Application)
- From: one-trick-pony
- Re: Batch file and MFC (Properly Terminating Application)
- References:
- Re: Batch file and MFC (Properly Terminating Application)
- From: Joseph M . Newcomer
- Re: Batch file and MFC (Properly Terminating Application)
- From: Alexander Grigoriev
- Re: Batch file and MFC (Properly Terminating Application)
- From: Joseph M . Newcomer
- Re: Batch file and MFC (Properly Terminating Application)
- From: one-trick-pony
- Re: Batch file and MFC (Properly Terminating Application)
- From: Scott McPhillips [MVP]
- Re: Batch file and MFC (Properly Terminating Application)
- From: one-trick-pony
- Re: Batch file and MFC (Properly Terminating Application)
- From: Scott McPhillips [MVP]
- Re: Batch file and MFC (Properly Terminating Application)
- From: one-trick-pony
- Re: Batch file and MFC (Properly Terminating Application)
- From: Scott McPhillips [MVP]
- Re: Batch file and MFC (Properly Terminating Application)
- From: Joseph M . Newcomer
- Re: Batch file and MFC (Properly Terminating Application)
- From: one-trick-pony
- Re: Batch file and MFC (Properly Terminating Application)
- From: one-trick-pony
- Re: Batch file and MFC (Properly Terminating Application)
- Prev by Date: Escape key
- Next by Date: Visual Studio 2005 project with files in multiple directories
- Previous by thread: Re: Batch file and MFC (Properly Terminating Application)
- Next by thread: Re: Batch file and MFC (Properly Terminating Application)
- Index(es):
Relevant Pages
|
Loading