Solved

CPU Usage

Posted on 2003-11-19
4
444 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:Rahulsaxena
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 9781683
You could use

SetThreadPriority ( GetCurrentThread (), THREAD_PRIORITY_IDLE);

to lower your main thread's priority.
0
 
LVL 6

Expert Comment

by:GloomyFriar
ID: 9789749
Why don't you like Sleep()?
0
 

Author Comment

by:Rahulsaxena
ID: 9790082
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
 
LVL 6

Expert Comment

by:GloomyFriar
ID: 9795855
And it will be the answer ;-)
But I think that the additional thread is right thing in this case.
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question