Re: Help with a long running process?
- From: Kyote <kyote_love@xxxxxxxxxxxxxxxxx>
- Date: Tue, 20 Mar 2007 02:29:06 -0500
Thank you very very much Branco. This does indeed look like what I
need to solve the problem.
On 19 Mar 2007 14:27:29 -0700, "Branco Medeiros"
<branco.medeiros@xxxxxxxxx> wrote:
<snip>This is what I was having the trouble with. I had hoped there was
Before the loop enters its initial cicle, it will first have to grab
all the files from all sub folders off the base path you specified.
something I didn't know about that would allow me to do a DoEvents in
there. As I'm constantly finding situations where there are more
elegant and much simpler ways to accomplish some of the things I'm
writing code for.
You can't put a DoEvents into this, cause it all will happen in theThats exactly what I was doing. I was parsing the filenames, for each
GetFiles() instruction. Also, there's not much sense to put this in a
loop unless you want to do something with each file.
file, into smaller segments. Then adding all bits dealing with that
filename into a class to store the parsed info. I was then adding each
class to a List.
One possible way to execute what you want is just to assign the arrayI had initially started with something fairly similar to this. Then I
of file names directly to listOfFiles (which I assume is a List(Of
String)) or return it as an array.
Nevertheless, if you want to have some control over the loop, you may
consider loading the files folder by folder:
<aircode>
Sub LoadFiles(ByVal Folder As String, _
ByVal List As List(Of String))
Dim Items() As String = _
System.IO.Directory.GetFiles(Folder)
ShowProgress(Folder, Items)
Application.DoEvents() '<-- Ops...
List.AddRange(Items)
For Each SubFolder As String _
In System.IO.Directory.GetDirectories(Folder)
Try
LoadFiles(SubFolder, List)
Catch Ex As Exception
End Try
Next
End Sub
</aircode>
As you can see, it's a recursive method that calls itself for each sub
folder. The 'Ops...' remark near DoEvents is just to remind you that
there are better ways to keep the UI alive during a long operation
(threads or the background worker, for instance). Anyway, this may
become your starting point...
found a supposedly simpler way to do this and changed it around. But
that was back when I was only dealing with about 5,000-10,000
filenames. I completely forgot about it. Thank you for pointing it out
to me. This should solve the problem.
Kyote wrote:LMAO, I'm happy to see it's not just me. Speaking of which, how do
I'm trying to make, what I thought, would be a simple application.
Join the club... =)))
you, more effectively, deal with program idea/concept improvements?
I often think of a simple app I'd like to make to simplify something I
want to do. Then while I'm writing away at it I get the 'Brillant'
idea for an improvement, or added feature. Something that can
'supposedly' make the app so much better than my original idea would
have been. But after a couple of those I sometimes get pretty confused
and frustrated.
Is there some kind of best practice or something for managing new
idea's/features? I guess I can stubbornly stick to my original app
specifications. Then once it's finished maybe then go back and revise
them. But is there a better way?
---
Kyote
.
- Follow-Ups:
- Re: Help with a long running process?
- From: Branco Medeiros
- Re: Help with a long running process?
- References:
- Help with a long running process?
- From: Kyote
- Re: Help with a long running process?
- From: Branco Medeiros
- Help with a long running process?
- Prev by Date: Re: How to fix this String to Long Error??
- Next by Date: Re: Is VB Caca??
- Previous by thread: Re: Help with a long running process?
- Next by thread: Re: Help with a long running process?
- Index(es):
Relevant Pages
|
Loading