AfxBeginThread Question
I'm new to the environment of MFC, for I prefer Win32 whenever possible, but
I'm beginning to view the potential of MFC. I've a question about
AfxBeginThread.
I'm developing an application that uses two checkbox buttons. When you
click one checkbox the other checkbox becomes disabled, for the two events
associated with each button are mutually exclusive -- you can only do one at
a time.
The pseudocode is as follows...
If User Clicked CheckBoxXXX
OtherCheckBox.Disable();
MyClass.DoYourFunction(&CheckBoxXXX);
OtherCheckBox.Enable();
EndIf
Now MyClass.DoYourFunction has one argument, a CButton. All it does is the
following...
void MyClass::DoYourFunction(CButton *button)
{
while (button->GetCheck() == BST_CHECKED)
{
//Interface with COM/OLE
}
}
But this loop will never end as this function call is not multithreaded.
I've been working with old Win32 function calls such as _beginthread and
making the function call static and changing the arguments to void's, but for
some reason, WaitForSingleObject isn't working correctly, so I'm looking at
AfxBeginThread.
Is it possible to still call AfxBeginThread on my function call WITHOUT
deriving the class from CWinThread? That's a lot of overhead that is
unnecessary for my simple function call. I know I would need to change the
return type and arguments as follows...
UINT MyClass::DoYourFunction(LPVOID pVoid)
{
CButton *btn;
btn = (CButton*)pVoid;
...
}
Thank you.