Using Multiple threads

Can someone tell me how to use multiple threads.  I am retrieving data through a Comm port and I am calling a progress bar dialog (included with MS VS 6.0).  I want the progress bar to count up as I'm downloading the data but I believe I need to use another thread to do the progress bar while the ReadFile function is getting the data.  Also, is there a way I can check to see what percentage of the bytes are recieved while I'm downloading or do I have to update my progress bar with a timer.
dociebAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AlexFMCommented:
To learn multithreading basics check out MFC sample MTRECALC.

COM port handling (including multithreading and asynchronous I/O):
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp

It is beter to move progress bar in the main application thread. COM port handling must run in the worker thread. Don't use blocking calls, use asynchronous overlapped I/O operations.
jkrCommented:
I'd also suggest to check out http://msdn.microsoft.com/library/en-us/dndllpro/html/msdn_threads.asp ("Multithreading for Rookies")

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hemakumarCommented:
Go thru these functions in msdn and call them where u require to start a thread.

1)AfxBeginThread
or
CreateThread functions.

There are two ways for readind data from comm port.one is using

ReadFile which is a synchronous call or say a blocking call as alex said which means function will not return till the i/o  is completed.
Instead of this use

ReadFileEx function which calls a callback function once operation is completed.



It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.