private void GetColor(object sender, DoWorkEventArgs e) { while (AntiDouble == false) { if (!GameManager.PreviousColors.Contains(GameManager.Color) && GameManager.Colors.Contains(GameManager.Color)) { if (GameManager.Color == "Blue") { Trivia.Bombs[0] = true; GameManager.PreviousColors.Add("Blue"); } if (GameManager.Color == "Green") { GameManager.PreviousColors.Add("Green"); Trivia.Bombs[1] = true; } if (GameManager.Color == "Yellow") { GameManager.PreviousColors.Add("Yellow"); Trivia.Bombs[2] = true; } if (GameManager.Color == "Red" && Trivia.Bombs[0] && Trivia.Bombs[1] && Trivia.Bombs[2]) { dmxeffects.bombsdone(4, 3); DisplayEndscreen = true; GameManager.PreviousColors.Add("Yellow"); } if (GameManager.Color == "Red" && Trivia.Bombs.Contains(false)) { return; } if (w8.CancellationPending == true) //Check for Cancellation Request { e.Cancel = true; break; } break; } } if (DisplayEndscreen) { GameManager.KeepCounting = false; w6.CancelAsync(); MethodInvoker EindForm = delegate { Hide(); Controller.DisconnectGamepad(); Socket.DisconnectStream(); w8.CancelAsync(); EindScherm obj = new EindScherm(); Hide(); obj.Closed += (s, args) => Close(); obj.Show(); }; Invoke(EindForm); return; } if (AntiDouble || DisplayEndscreen) { return; } Controller.DisconnectGamepad(); Socket.DisconnectStream(); MethodInvoker startForm = delegate { Hide(); w8.CancelAsync(); KeuzeScherm obj = new KeuzeScherm(); Hide(); obj.Closed += (s, args) => Close(); obj.Show(); }; Invoke(startForm); return; }