public void TestThread() { DataRoulette data = new DataRoulette(); ThreadRoulette thread = new ThreadRoulette("Pasha's thread! Cool!"); // Если раскоментить то все получиться) Урааа) круто)) ахха thread.Thrd.Join(); Assert.IsNotNull(thread.RoulutteData); }
private void StartThreads() { ThreadRoulette.StartTimer(); if (user.CurrentPoints >= 30) { ThreadRoulette.StopTimer(); // Create new thread Thread fruitThreads = new Thread(new ThreadStart(() => { // Create our context, and install it: SynchronizationContext.SetSynchronizationContext( new DispatcherSynchronizationContext( Dispatcher.CurrentDispatcher)); Dispatcher.CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Background); // The main work thread1 = new ThreadRoulette("Thread roulette 1"); thread2 = new ThreadRoulette("Thread roulette 2"); thread3 = new ThreadRoulette("Thread roulette 3"); // Если потоки не синхронизировать то все значения будут одинаковы!!! thread1.Thrd.Join(); thread2.Thrd.Join(); thread3.Thrd.Join(); // The main work // Start the Dispatcher Processing System.Windows.Threading.Dispatcher.Run(); })); fruitThreads.Start(); fruitThreads.Join(); control1.DataContext = thread1.RoulutteData; control2.DataContext = thread2.RoulutteData; control3.DataContext = thread3.RoulutteData; txtTimer.Text = "The system is thinking: " + ThreadRoulette.TimeElapsed.ToString() + " sec"; SayResults(); if (user.CurrentPoints >= 1000) SayWin(); } else { MessageBox.Show("Get a credit"); return; } //ThreadRoulette.StartTimer(); //if (user.CurrentPoints >= 30) //{ // user.CurrentPoints = user.CurrentPoints - 50; // thread1 = new ThreadRoulette("Thread roulette 1"); // thread2 = new ThreadRoulette("Thread roulette 2"); // thread3 = new ThreadRoulette("Thread roulette 3"); // // Если потоки не синхронизировать то все значения будут одинаковы!!! // thread1.Thrd.Join(); // thread2.Thrd.Join(); // thread3.Thrd.Join(); // control1.DataContext = thread1.RoulutteData; // control2.DataContext = thread2.RoulutteData; // control3.DataContext = thread3.RoulutteData; // txtTimer.Text = "The system is thinking: " + ThreadRoulette.TimeElapsed.ToString() + " sec"; // SayResults(); // if (user.CurrentPoints >= 1000) // SayWin(); //} //else //{ // MessageBox.Show("Get a credit"); // return; //} //ThreadRoulette.StopTimer(); }