Re: CProgressBar and threads by Joachim
Joachim
Tue Aug 19 10:23:09 CDT 2003
Thanks Anand,
However, I encountered problems when trying to do the user
interface thread: The user interface is a dialog (inherits
from CDialog) and have to inherit from CWinThread
(according to MSDN). When compiling this I get the
following error when trying to create a new object of my
class:
error C2385: 'CMyClass:new' is ambiguous
Why this error and how do I solve it?
Thanks,
Joachim
>-----Original Message-----
>Hi Joachim,
>
>There are two kind of threads in MFC, Worker Thread and
>User interface theread. Worker thread will run in
>background and you do not have to wait for it to
continue.
>There is no MSG queue in worker thread. User Interface
>thread provides a message queue and useful in interactive
>user interface.
>
>You can create worker thread using AfxBeginThread() and
>pass controlling function as first parameter.
>
>For user interface thread you can use same AfxBeginThread
>() function. But in this case pass first parameter as
>Runtime class object. RUNTIME class is class derived from
>CWinThread. Alternative to this method is to use
>CreateThread() method. In previous case AfxBeginThread
>will call CreateThread() internally.
>
>So now in your application create a worker thread for
>background processing and then start procesing. It you
>have UserInteface, you have User interface thread running
>so display your progress bar using that thread.
>
>I'd suggest you to read Threading document of MFC on MSDN
>web site / CD. Chekc the CWinThread class help, there
>you'd get lot more details regarding threading in MFC.
>
>Enjoy...
> Anand Raval
> (remove 1 for email)
>
>
>>-----Original Message-----
>>I'd like to popup a window with a CProgressBar bar when
>>doing a series of actions. I know I need to use threads
>>for this. I know the concept of threads, but not at all
>>how you do anything with threads in MFC. Can anyone help?
>>
>>Thanks,
>>Joachim
>>.
>>
>.
>