Using ParameterizedThreadStart would almost work but it requires object as parameter, which feels very wrong. Is it possible to pass a String through ParameterizedThreadStart?
public void OpenUDirectory(String Directory)
{
Items.Clear();
foreach (FileInfo FI in new DirectoryInfo(Directory).GetFiles())
{
Items.Add(FI.Name);
}
}
I came up with the idea of adding an extension constructor to ParameterizedThreadStart so that I could cast String to Object and call the base method, but is there a cleaner way?
I’m sure I need to call the Invoke method so I have a delegate:
public delegate void OpenDD(String Directory);
You have to box is as an
objectwhen you start the thread. Then cast it back to astringand call your method.That is the way it works since it gives the greatest range of flexibility.