I am developing Windows Form C# program which reads Excel data from shared drive every 20 minutes (I'm using "Timer") - function "inserting". I want to read multiple Excel files at once because of the performance. For that reason I'm using threads. 

Each thread is calling a function (LoadExcelData) which reads data from Excel to ArrayList. I want to know when all threads are finished (when all excel files were loaded to ArrayList) in order to insert this ArrayList to internal database. 

I tried with thread[i].Join() but this freezes GUI. I also do not know what would happen if I have 100+ files and for this reason 100+ threads. Would that cause memory exception or some other exception? 

```
        //Execute every 20 minutes  (Timer). Do not Execute in case previouse run is not finished
        void inserting(List<String> excels){

        int numOfThreads=excels.length;
        Thread[] threads = new Thread[numOfThreads];
        for (int index = 0; index < numOfThreads; index++)
        {
            int i = index;
            threads[index] = new Thread(() =>
                {
                    LoadExcelData(excels[i].File_name); //function loads excel data to global array "Weather" which is used later on
                });
        }

       for (int i = 0; i < threads.Length; i++)
        {
            threads[i].Start(); //start thread
        }

        for (int i = 0; i < threads.Length; i++)
        {
            //   threads[i].Join(); //this freezes GUI!
        }

       InsertToDB(object of ArrayList<ClassName>); //insert data which was read from Excels

       isRunning=false;//Data was successefully inserted to DB 
     }

```

I want to run this every 20 minutes. I'm using Timer:

```
    timer = new System.Windows.Forms.Timer();
    timer.Tick += new EventHandler(timerEventHanlder);
    timer.Interval = 20 * 60000; // in miliseconds
    timer.Start(); 

private void timerEventHanlder(object sender, EventArgs e)
{
   List<String> excels = getExcels();
    if (!isRunning){ //in case previous timer even is not finished wait another 20 minutes...
        isRunning=true; //flag to true
        inserting(excels);
       }
}

```

Is there any better wait to solve above problem?