Solved

CPU Usage

Posted on 2003-11-19
4
439 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
  • 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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Macro to save highlighted rows as a separate file 5 43
Change owner from userA to server Local Administrators 7 62
matchUp  challenge 6 62
fix34  challenge 9 118
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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…
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

772 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