Solved

CPU Usage

Posted on 2003-11-19
4
436 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
Comment Utility
You could use

SetThreadPriority ( GetCurrentThread (), THREAD_PRIORITY_IDLE);

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

Expert Comment

by:GloomyFriar
Comment Utility
Why don't you like Sleep()?
0
 

Author Comment

by:Rahulsaxena
Comment Utility
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
Comment Utility
And it will be the answer ;-)
But I think that the additional thread is right thing in this case.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now