C
Craig Vermeer
Hi All,
I have a program that's using the file system as a queuing mechanism,
and it's consuming an inordinate amount of CPU time when the file system
queue gets all that large (any more than a thousand or so messages in
the queue).
I know why. It's because my code to grab a single message off the queue
looks something like this :
//m_folder is a DirectoryInfo object
FileInfo file = m_folder.GetFiles("*.xml")[0];
So, it's pulling info about every file in the queue _every time_ it
wants to get a message from the queue.
Where I'm struggling, though, is finding a more efficient way to get the
first file in the directory.
One approach I can think of is to do some in-memory caching of the list
of files, so that I don't read them from disk every time. However,
there's a fair amount of effort involved there, because my program
reading the messages from the queue is multithreaded.
So, before I go down that route I thought I'd ask around. Anyone know
of a very efficient way to just pull a single file from a directory?
Thanks,
Craig
I have a program that's using the file system as a queuing mechanism,
and it's consuming an inordinate amount of CPU time when the file system
queue gets all that large (any more than a thousand or so messages in
the queue).
I know why. It's because my code to grab a single message off the queue
looks something like this :
//m_folder is a DirectoryInfo object
FileInfo file = m_folder.GetFiles("*.xml")[0];
So, it's pulling info about every file in the queue _every time_ it
wants to get a message from the queue.
Where I'm struggling, though, is finding a more efficient way to get the
first file in the directory.
One approach I can think of is to do some in-memory caching of the list
of files, so that I don't read them from disk every time. However,
there's a fair amount of effort involved there, because my program
reading the messages from the queue is multithreaded.
So, before I go down that route I thought I'd ask around. Anyone know
of a very efficient way to just pull a single file from a directory?
Thanks,
Craig