private void timer1_Tick(object sender, EventArgs e) { DateTime nowTime = DateTime.Now; cr = CSVManager.GetActiveJobs(); if (cr.Count == 0) { return; } runTime = new DateTime(nowTime.Year, nowTime.Month, nowTime.Day, cr[0].hours, cr[0].minutes, 0); if (DateTime.Now.Hour == runTime.Hour && DateTime.Now.Minute == runTime.Minute) { RegistrationManager RegMan = new RegistrationManager(api.getClubOpenRegistrations(cr[0].matchID.ToString()), CommonFunctions, cr[0].matchID.ToString()); RegMan.PrepareData(); CSVManager.UpdateOrInsertCSV(cr[0].matchID.ToString()); // start on different thread Task mytask = Task.Run(() => { StatusPoruka.Text = RegMan.ExportToExcel(); }); ShowDgvData(); } }