CPU Usage

hi@
I have an MFC application that does a FTP operation and after downloading parses the file. One thing I noticed in the operation is that till the application terminates the CPU is completely occupied and so all the other applications such as opening Internet Explorer or any windows operation just freezes.
IS there any way that I can make my application light weight without using Thread.Any function apart from Sleep that gives the other windows applications an equal share of CPU usage.

thanks
rahul
RahulsaxenaAsked:
Who is Participating?
 
jkrConnect With a Mentor Commented:
You could use

SetThreadPriority ( GetCurrentThread (), THREAD_PRIORITY_IDLE);

to lower your main thread's priority.
0
 
GloomyFriarCommented:
Why don't you like Sleep()?
0
 
RahulsaxenaAuthor Commented:
Because , Sleep just does'nt do anything with the CPU. it just stops the process, I was expecting the main thread to stop processing and process the event messages from the user.
I guess, I am left with two choices, Peek Message Loop or spawn a worker thread that processes the data and let the main thread respond to user events.

Anyways you question is quite amusing ;)
Yes, I like sleeping

0
 
GloomyFriarCommented:
And it will be the answer ;-)
But I think that the additional thread is right thing in this case.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.