Hi,

I have a button where I run 4 tasks asynchronously, result is some string based on looping through many directories on my FileSystem. If I start clicking on a button continuously everything get's messed up, because some previous taks are still running in parallel. Here is my code :

Code:
    var tests = new[]
            {
                Task.Factory.StartNew(() => Test1()),
                Task.Factory.StartNew(() => Test2()),
                Task.Factory.StartNew(() => Test3()),
                Task.Factory.StartNew(() => Test4()),
            };

            Task.WaitAll(tests);
From what I read I could use Task.WhenAll, but I can't manage It correctly. Can somebody show me how should It look like ?