-
Do until loop bogging down cpu help? Please?
I am using a do until loop to wait for a file to be generating before my code
executes the following task. Is there anyway to lower the amount of cpu
% the loop uses while the procees that generates the file executes?
Thanks
-
Re: Do until loop bogging down cpu help? Please?
David,
Put a call to System.Threading.Sleep in side of your loop to temporarily
suspend the current thread. Consider starting with 500 ms to start (half a
second).
Another option is rather than use a hard loop which is rarely good in a
multiple process system as you are finding out. Use a System.Threading.Mutex
to cause the one job to wait until the other process says that the file is
generated. This is very CPU friendly. The Mutex constructor that accepts a
string can be used for cross-process communication...
Hope this helps
Jay
"david" <ddreeder@hotmail.com> wrote in message
news:3df66025$1@tnews.web.devx.com...
>
> I am using a do until loop to wait for a file to be generating before my
code
> executes the following task. Is there anyway to lower the amount of cpu
> % the loop uses while the procees that generates the file executes?
>
> Thanks
-
Re: Do until loop bogging down cpu help? Please?
If you are waiting on a file to be created or changed use the FileWatcher
object and it will raise an event when the file is created, modified or
changed. Works great!
"david" <ddreeder@hotmail.com> wrote in message
news:3df66025$1@tnews.web.devx.com...
>
> I am using a do until loop to wait for a file to be generating before my
code
> executes the following task. Is there anyway to lower the amount of cpu
> % the loop uses while the procees that generates the file executes?
>
> Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks