Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to reduce resource utilization

Status
Not open for further replies.

foxbldr

Programmer
Apr 16, 2002
109
CA
Hi Everybody,

I want my VFP6 application to monitor a particular folder for some newly created txt files continuously. When I use following code, computer's utilization goes upto 100% level.
Can somebody suggest me how to achieve the same without using much resources?
Code:
llContinue=.t.
on escape do stopApp && llContinue=.f.
do while llContinue
  ....
  this.checkFolder(...)
  .....
enddo

Foxbldr
 
Create a COM with a timer set to delay every X seconds (your choice) that reads in the directory (adir()) and displays it.
 
Hi Foxbldr,

In your VFP application from where ever you are running the code at present..

Code:
Your code .........
llContinue=.t.
on escape do stopApp && llContinue=.f.
do while llContinue
  ....
  this.checkFolder(...)
  .....
enddo

I suggest you to replace it in that form with a timer.
For example drop a timer control in that form and then set the following for the timer control property.
myTimer.Interval = 5000
That is it will fire every 5000 milli seconds i.e. every 5 seconds.

Then put in its Timer event the code you need..

this.checkFolder(...)
Do whatever...

To stop the timer all you have to do is release that form or remove the timer object by code. To restart add it with AddObject(myTImer) suitably into that form. But I think that is not at all needed, once you run it using timer control.

:)





____________________________________________
ramani - (Subramanian.G) :)
 
foxbldr

I would do as WayIsThisInUse suggests, create a COM and put it in a schedule task (outside of your own appliation) and use the ReadDirectoryChangesW API call to verify any changes done inside the directory.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hi everybody,

Thank you all for the suggestions.

When I used the timer control, I noticed a siginificant change in resource utilization.
Code:
**//in timer1.timer event //**

if !thisform.busy
   thisform.busy=.t.
   do whatever..
   .............
   .............
   thisform.busy=.f.
endif

I used a form property to flag the timer the status of the process.

Foxbldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top