A
Andy Williams
Apologies in advance for the long post.
I have an application which has 2 CheckedListBox controls, CLB 1 is a list
of Directories and CLB 2 is a list of Files.
Directories can be added to CLB 1 by clicking an Add button.
Users can Check Directories in CLB 1 and the app then populates CLB2 with a
list of Files in the Checked Directories. In some cases there can be a large
number of files in the directories so it can take a long time to populate CLB
2 and whilst this population takes place the app hangs.
So, I've started to look at threading. I've managed to create a Finder Class
that is started as a thread on the Item_Click event of CLB1. This seems to
work OK in that it allows the app to continue to repond to user input e.g.
clicking the Add button or Checking an item in CLB1. The problem is that I
need to suspend or in some cases cancel the Finder thread depending on what
the users does. For example if the User clicks Directory 1 it is Checked and
the Finder goes off and finds the files in Directory 1 and adds them 2 CLB 2.
However if, whilst the Finder is still running the User clicks Directory 1
again then it is Unchecked and we need to remove all the files from Directory
1 from the CLB 2 but because the Finder is running it will keep adding files
it hasn't yet found unless it is stopped.
I need to know how to Suspend or Cancel the Finder thread without using
deprecated commands such as Suspend or Stop
I have an application which has 2 CheckedListBox controls, CLB 1 is a list
of Directories and CLB 2 is a list of Files.
Directories can be added to CLB 1 by clicking an Add button.
Users can Check Directories in CLB 1 and the app then populates CLB2 with a
list of Files in the Checked Directories. In some cases there can be a large
number of files in the directories so it can take a long time to populate CLB
2 and whilst this population takes place the app hangs.
So, I've started to look at threading. I've managed to create a Finder Class
that is started as a thread on the Item_Click event of CLB1. This seems to
work OK in that it allows the app to continue to repond to user input e.g.
clicking the Add button or Checking an item in CLB1. The problem is that I
need to suspend or in some cases cancel the Finder thread depending on what
the users does. For example if the User clicks Directory 1 it is Checked and
the Finder goes off and finds the files in Directory 1 and adds them 2 CLB 2.
However if, whilst the Finder is still running the User clicks Directory 1
again then it is Unchecked and we need to remove all the files from Directory
1 from the CLB 2 but because the Finder is running it will keep adding files
it hasn't yet found unless it is stopped.
I need to know how to Suspend or Cancel the Finder thread without using
deprecated commands such as Suspend or Stop