public MainWindow() { DatabaseClass databaseClass = new DatabaseClass(monitor12); EventCreatorClass eventCreatorClass = new EventCreatorClass(monitor12, monitor23, databaseClass, events); EventLoaderClass eventLoaderClass = new EventLoaderClass(monitor23, events); List <Thread> threads = new List <Thread>(); InitializeComponent(); SeleniumClass selenium = new SeleniumClass(ComboGroup, ComboSemester, INFO, USER, PASS, HIDE); StartButton.Click += (sender, EventArgs) => StartButton_Click(sender, EventArgs, databaseClass, eventCreatorClass, eventLoaderClass, threads); CancelButton.Click += (sender, EventArgs) => Cancel_Click(sender, EventArgs, threads); LoginButton.Click += (sender, EventArgs) => LoginClick(sender, EventArgs, selenium); SelectButton.Click += (sender, EventArgs) => SelectClick(sender, EventArgs, selenium); DownloadButton.Click += (sender, EventArgs) => DownloadClick(sender, EventArgs, selenium); }
private void StartButton_Click(object sender, RoutedEventArgs e, DatabaseClass databaseClass, EventCreatorClass eventCreatorClass, EventLoaderClass eventLoaderClass, List <Thread> threads) { Thread databaseThread = new Thread(() => databaseClass.UploadCoursesToDatabase(DBLog, DBCounter, S1Red)); threads.Add(databaseThread); Thread creatorThread = new Thread(() => eventCreatorClass.CreateEvents(EventCreateLog, S1Red, EventCreatedCounter, CreatorLight, LoaderLight)); threads.Add(creatorThread); Thread loaderThread = new Thread(() => eventLoaderClass.EventUpload(EventLoaderLog, EventCreateLog, EventCreatedCounter, LoaderCounter, LoaderLight, CreatorLight, S1Red, StartButton, CancelButton, DeleteButton)); threads.Add(loaderThread); foreach (var th in threads) { th.Start(); } StartButton.Visibility = Visibility.Hidden; CancelButton.Visibility = Visibility.Visible; DeleteButton.IsEnabled = false; }