I have this function which takes a path and searches for a file in it. I have two approaches: one is to make the main thread do the job, and the another is to make a worker thread do the job. When the main thread does the job it returns all the files but when a worker thread does the job it returns only a small number of the files in that path only. It doesn't do the recursion step which enters sub-directories. Here is the code:

```
public void  GetAllFiles(string sdir)
        {

                foreach (string dir in Directory.GetDirectories(sdir))
                {

                    try
                    {
                        foreach (string file in Directory.GetFiles(dir, "*.*"))
                        {
                            string filename = Path.GetFileName(file);

                            listView1.Items.Add(filename);

                        }
                        GetAllFiles(dir);
                    }
                    catch (Exception error)
                    {
                        Console.WriteLine(error.Message);
                    }
                }
            } 

```

and here is how i call the thread:

```
 Thread thread = new Thread(() => GetAllFiles("C:\\Users\\modz\\Desktop\\games"));
 thread.Start();

```