CMyProgDlg. App refers to the first. I don't mean it as a shortened
form of the word Application.
I will look in to I/O Completion ports, thanks.
Joseph M. Newcomer wrote:
This question is ill formed.
An app is an executable image. You can't say "the Dlg and the App run in two separate
threads". You can have two threads, but the concept that "the App" is distinct from any
other component of the executable doesn't make sense.
You might consider using a queuing mechanism between the two. I/O Completion Ports make a
nice queuing system. For once every second or so, you could also use PostMessage or
PostThreadMessage.
joe
On 18 Aug 2006 14:18:21 -0700, "PaulH" <paul.heil@gmail.com> wrote:
I have an MFC app that can be used with or without the dialog (GUI)
component. The dialog is an optional status component that updates with
statistics every second. I'd like to put all the statistical
calculations and queries in the App. The Dlg and the App run in two
separate threads.
My question is: what's the best OO method of doing this?
1. Do I put a timer in the dialog and have it get the data from the app
every second?
CMyDlg::OnTimer()
{
STATISTICS stats;
((CMyApp *)GetParent())->GetStatistics(&stats);
//...
}
2. Do I send a pointer to the statistics to the dialog from the App and
just have the dialog read that every second?
CMyApp::CreateDialog(CWnd *pParent)
{
m_pDialog = new CMyDlg();
m_pDialog->SetStatisticsPointer(&m_statPointer);
m_pDialog->Create(IDD_MY_DLG, pParent);
//...
}
Neither of these strikes me as a particularly fantastic solution... Is
there a better way?
Thanks,
PaulH
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm