S
SStory
Here is the situation.
I want to display Icons, Type of file etc from a file extension.
Upon initial program load I may only need icons for certain files. But
other operations will require showing all filetypes and icons. I have an
object that has extension, desc (like Word Document) and then icon, which is
nothing to start with.
I have a collection object of these and when it is initialized it goes to
the registry to get all extensions registered and their file type desc.
automatically (this is very fast) the collection has a hashtable for
lookups although items are stored in the collection derived from
collectionbase.
Getting the icons for each of these (647 on my system) takes 14-28
seconds--eternity for users.
So I wanted to make a background thread that starts before my splash
screen--or at some time and starts going through the collection 0....N
calling a method on the class in the collection to tell it to get its
associated icon.
However, should I need x specific icons before this process terminates I
would like to be able to tell the thread to either pause or save current
index, stop that and use another method to go get ".exe,.doc,.zip" or
whatever limited list I immediately need.
I am really confused as to how to go about this. I have read the WROX
professional book on Threading and have a basic understanding.
I have my own app class that is accesible to the entire application and my
FileInfo collection is part of it.
Questions:
1.) How do I have a thread getting these, yet access the ones I need if I
need some before it gets finished?
Do I launch the thread and let it populate this collection and then
call a method in that thread to say pause and get these and return them as a
separate mini collection? (but the apps collection would be running in a
separate thread.)
Or do I tell the thread to fill up its own private version of the collection
and when done pass that to the app object which will overwrite it's own
object? If so how? I was planning to use the manualresetevent which will
allow thread pausing. How would I then tell it to get what I need at
present? Would I have a method in the thread to call passing what I need
and it send back the collection as is including those items that I told it
to get and me overwrite the master collection in my app object? And would I
need a readerwriterlock in the app for the collection? Seems I would?
Also since the app could want to access it's collection at any time(being
called from my program to get that collection) do I somehow need to sync its
access?
I am close to understanding but missing something.
Could anyone please help me get this straight and tell me what is the best
way to do it?
Seems that if I need a readerwriterlock in my app object for dealing with
when the collection of fileinfo is accessed, that if it can be read then I
don't need to worry about the collection internal Item method having sync
problems?
What issues am I missing and how?
Thanks,
Shane
I want to display Icons, Type of file etc from a file extension.
Upon initial program load I may only need icons for certain files. But
other operations will require showing all filetypes and icons. I have an
object that has extension, desc (like Word Document) and then icon, which is
nothing to start with.
I have a collection object of these and when it is initialized it goes to
the registry to get all extensions registered and their file type desc.
automatically (this is very fast) the collection has a hashtable for
lookups although items are stored in the collection derived from
collectionbase.
Getting the icons for each of these (647 on my system) takes 14-28
seconds--eternity for users.
So I wanted to make a background thread that starts before my splash
screen--or at some time and starts going through the collection 0....N
calling a method on the class in the collection to tell it to get its
associated icon.
However, should I need x specific icons before this process terminates I
would like to be able to tell the thread to either pause or save current
index, stop that and use another method to go get ".exe,.doc,.zip" or
whatever limited list I immediately need.
I am really confused as to how to go about this. I have read the WROX
professional book on Threading and have a basic understanding.
I have my own app class that is accesible to the entire application and my
FileInfo collection is part of it.
Questions:
1.) How do I have a thread getting these, yet access the ones I need if I
need some before it gets finished?
Do I launch the thread and let it populate this collection and then
call a method in that thread to say pause and get these and return them as a
separate mini collection? (but the apps collection would be running in a
separate thread.)
Or do I tell the thread to fill up its own private version of the collection
and when done pass that to the app object which will overwrite it's own
object? If so how? I was planning to use the manualresetevent which will
allow thread pausing. How would I then tell it to get what I need at
present? Would I have a method in the thread to call passing what I need
and it send back the collection as is including those items that I told it
to get and me overwrite the master collection in my app object? And would I
need a readerwriterlock in the app for the collection? Seems I would?
Also since the app could want to access it's collection at any time(being
called from my program to get that collection) do I somehow need to sync its
access?
I am close to understanding but missing something.
Could anyone please help me get this straight and tell me what is the best
way to do it?
Seems that if I need a readerwriterlock in my app object for dealing with
when the collection of fileinfo is accessed, that if it can be read then I
don't need to worry about the collection internal Item method having sync
problems?
What issues am I missing and how?
Thanks,
Shane