I have a Windows service running that deletes folders from a network drive. I want to make deletion asynchronous. How can I do that?
Now I go through the catalogs and call
Directory.Delete(fullPath, true);
thank
I would use a parallel task library:
Task.Factory.StartNew(path => Directory.Delete((string)path, true), fullPath);
If you are looping, you can use parallel foreach
// assuming that you have a list string paths. // also assuming that it does not matter what order in which you delete them Parallel.ForEach(theListOfDirectories, (x => Directory.Delete(x));