Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a listview that I populate with file names from a folder that is being watched (using FileSystemWatcher via "AddHandler FileWatch.Created, AddressOf FileWatchNewFile"). When a new file is created in the folder, it is added to the listview from the FileWatchNewFile function.

 

Processing each file could take up to a minute or two, so the listview could contain dozens of entries that are waiting to be processed. Once a file is processed, it is flagged/removed. It's possible that all the files could be processed so that the listview becomes empty.

 

My question is this: What is the best way to watch the listview in order to process the entries (filenames) as they show up?

Should I use a timer that would fire every 10 seconds to see if the file processing code is waiting to be called? What if the file processing code is still processing a file?

 

Hopefully you get the idea.

 

tia

flynn

Posted

I would have a global boolean blRunning that you set to true when the file processing code starts and false when it finishes. When each file is added to the listbox I would check if blRunning is false and if so call the file processing code. The file processing code, once finsihed with one file should then check if the listbox has any items still in it and if so process another one.

 

In this way the fileprocessing code will run until the listbox is empty and then start up again when another file is added.

 

:)

Please check the Knowledge Base before you post.

"Computers are useless. They can only give you answers." - Pablo Picasso

The Code Net

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...