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!

Refreshing the GUI 2

Status
Not open for further replies.

cruise95

Programmer
Oct 7, 2003
56
US
Background:
A file is fist FTP-ed to a certain folder. Then my program identifies the file (sometimes using only the filename, but other times the file is opened up and it is searhed for any identifying text)

This process can be paused by checking a 'Pause' checkbox. A while loop runs while the checkbox is un-checked.

Problem:
When there are no files in the folder (for the program to process) then my program works ok - there is a little pause...but nothing upsetting. However, when there are files in the folder (and the checkbox is not checked) then the program is constantly running (of course) and the gui
rarely refreshes. Only a big white box surrounded by the window's border) appears.

I know that because of processing (and the while loop) the CPU rarely takes the time to refresh the GUI. The program eats up about 20 - 40% of the CPU's processing. I've added a lot of DoEvents() statements within the program.

The while loop is wanted so that the folder is constanty checked with no delay.

Question:
Is there something more that I can do so that the GUI refreshes and it does not behave in such a jagged manner?
 
Are ou using a FileSystemWatcher to watch for new files?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I tried the watcher, but when 10 files appeared in the folder at the same time, then not all of the 10 files were processed.

I should explore the watcher more though.
 
Yep it's because the filesystemwatchers buffer is set to small (default) you should increase it.



Christiaan Baes
Belgium

"Time for a new sig." - Me
 
thanx Christiaan,

I'm going to do some more testing on the file watcher. Do you know of any other good sources that describe the watcher?

For example, When is the NotifyFilter.created event raised? Is it raised once the file is initially seen in the directory or is it raised after the file has finiched loading?

I also wonder what events I should use? I was just concerned about the NotifyFilter.CreationTime but maybe I should use LastWrite or LastAccess instead.

Each file includes aproximatly 40 characters (2 bytes/character = 80 bytes) and the one CreationTimes event uses 16 bytes for a total of 96 bytes. An internatl Buffer of 4KB (4096 byes) will hold anout 42 files (4096 / 96). Why am I having trouble with 10 files? Maybe because some of those have the same creation time and are thus overlooked by the event?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top