Ejemplo n.º 1
0
        private void cmdAbort_Click(object sender, EventArgs e)
        {
            if (_visualisationThread?.ThreadState == ThreadState.Suspended)
            {
#pragma warning disable 618
                _visualisationThread?.Resume();
#pragma warning restore 618
                _visualisationThread.Abort();
            }
            else
            {
                _visualisationThread?.Abort();
            }
        }
Ejemplo n.º 2
0
	public static void Main ()
	{
		bool finished = false;

		Thread t1 = new Thread (() => {
			while (!finished) {}
		});

		Thread t2 = new Thread (() => {
			while (!finished) {
				GC.Collect ();
				Thread.Yield ();
			}
		});

		t1.Start ();
		t2.Start ();

		Thread.Sleep (10);

		for (int i = 0; i < 50 * 40 * 20; ++i) {
			t1.Suspend ();
			Thread.Yield ();
			t1.Resume ();
			if ((i + 1) % (50) == 0)
				Console.Write (".");
			if ((i + 1) % (50 * 40) == 0)
				Console.WriteLine ();
		}

		finished = true;

		t1.Join ();
		t2.Join ();
	}
Ejemplo n.º 3
0
 public static bool Resume()
 {
     try
     {
         if (_thread.ThreadState == ThreadState.Suspended)
         {
             _thread?.Resume();
             return(true);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         CallBacker.CallBackException?.Invoke(ex);
         return(false);
     }
 }
Ejemplo n.º 4
0
        private void btnPause_Click(object sender, EventArgs e)
        {
            if (paused)
            {
                btnPause.Text = "Pause";
                paused        = false;

                stopwatch.Start();
                checkerThread?.Resume();
            }
            else
            {
                btnPause.Text = "Resume";
                paused        = true;

                stopwatch.Stop();
                checkerThread?.Suspend();
            }
        }
Ejemplo n.º 5
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (!IsAuthorised())
            {
                MessageBox.Show("网络异常!", "Article Conversion Tool");
                return;
            }
            string btnText = this.button2.Text;

            if (btnText == "开始")
            {
                this.button2.Text = "暂停";
                folderPath        = this.textBox5.Text;
                wordPath          = this.textBox4.Text;
                htmPath           = this.textBox6.Text;
                txtPath           = this.textBox7.Text;
                if (string.IsNullOrEmpty(wordPath) || string.IsNullOrEmpty(folderPath))
                {
                    MessageBox.Show("目录不能为空!", "Article Conversion Tool");
                    return;
                }
                if (th2 == null)
                {
                    th2 = new Thread(ReadAllWordPath);
                    th2.IsBackground = true;
                    th2.Start();
                }
                else
                {
                    th2?.Resume();
                }
            }
            else
            {
                this.button2.Text = "开始";
                th2?.Suspend();
            }
        }
Ejemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!IsAuthorised())
            {
                MessageBox.Show("网络异常!", "Article Conversion Tool");
                return;
            }
            string btnText = this.button1.Text;

            if (btnText == "开始")
            {
                this.button1.Text = "暂停";
                folderPath        = this.textBox1.Text;
                targetPath        = this.textBox2.Text;

                if (string.IsNullOrEmpty(folderPath) || string.IsNullOrEmpty(targetPath))
                {
                    MessageBox.Show("目录不能为空!", "Article Conversion Tool");
                    return;
                }
                if (th1 == null)
                {
                    th1 = new Thread(ReadAllFolder);
                    th1.IsBackground = true;
                    th1.Start();
                }
                else
                {
                    th1?.Resume();
                }
            }
            else
            {
                this.button1.Text = "开始";
                th1?.Suspend();
            }
        }
Ejemplo n.º 7
0
        public void Run()
        {
            Thread tA = new Thread( new ThreadStart( ThreadA ) );
            Thread tB = new Thread( new ThreadStart( ThreadB ) );

            Thread.CurrentThread.Name = "Main thread";
            tA.Name = "Thread A";
            tB.Name = "Thread B";

            tA.Start();
            tB.Start();
            System.Console.WriteLine( "Suspending thread A" );
            Thread.Sleep( 100 );
            tA.Suspend();
            Thread.Sleep( 2500 );
            System.Console.WriteLine( "Suspending thread B" );
            tB.Suspend();
            Thread.Sleep( 2500 );
            System.Console.WriteLine( "Running GC..." );
            GC.Collect();
            System.Console.WriteLine( "Suspending main thread" );
            Thread.Sleep( 2500 );
            tA.Resume();
            _mreA.Set();
            Thread.Sleep( 2500 );
            tB.Resume();
            _mreB.Set();
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            //#1
            var allProcesses = Process.GetProcesses();

            foreach (var proc in allProcesses)
            {
                try
                {
                    Console.WriteLine($"ID: {proc.Id}\nName: {proc.ProcessName}\nPriority: {proc.PriorityClass}\nLaunch Time: {proc.StartTime}\nProcessor Time: {proc.TotalProcessorTime}");
                }
                catch (Exception e)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(e.Message);
                    Console.ResetColor();
                }
                Console.WriteLine();
            }

            //#2
            {
                Console.WriteLine("\n### Работа с доменами ###\n");
                AppDomain appDom = AppDomain.CurrentDomain;
                Console.WriteLine($"Current Domain's Name: {appDom.FriendlyName}\nId: {appDom.Id}");
                Console.WriteLine("\nDomain loaded assemblies:");
                Assembly[] assembs = appDom.GetAssemblies();
                foreach (var assemb in assembs)
                {
                    Console.WriteLine(assemb.ToString());
                }

                AppDomain newDomain = AppDomain.CreateDomain("MyNewDomain");
                newDomain.Load("SayHelloLib");
                Assembly[] loadedDomainAssemb = newDomain.GetAssemblies();
                Console.WriteLine("\nЗагруженные сборки созданного домена:");
                foreach (var assemb in loadedDomainAssemb)
                {
                    Console.WriteLine(assemb.ToString());
                }
                AppDomain.Unload(newDomain);
            }

            //#3
            {
                Console.WriteLine("\n### Работа с отдельным потоком ###\n");

                Thread th = new Thread(CountPrime);
                th.Name = "Поток вывода простых чисел на консоль";
                StreamWriter Writer  = new StreamWriter("Primes.txt");
                CountPrimes2 cprimes = new CountPrimes2(Writer, 200);
                Thread       th2     = new Thread(cprimes.Count);
                th2.Name = "Поток записи простых чисел в файл";
                th2.Start();
                th.Start(200);
                Thread.Sleep(2000);

                th.Suspend();
                Console.Write("Pausing second thread for a 3 secs ");
                Console.WriteLine(DateTime.Now);
                Console.WriteLine("Thread status: " + th.ThreadState);
                Console.WriteLine("Thread name: " + th.Name);
                Console.WriteLine("Thread priority: " + th.Priority);
                Console.WriteLine("Thread ID: " + th.ManagedThreadId);

                th2.Suspend();
                Writer.Write("Paused input for 3 seconds ");
                Writer.WriteLine(DateTime.Now);
                Writer.WriteLine("Thread status: " + th2.ThreadState);
                Writer.WriteLine("Thread name: " + th2.Name);
                Writer.WriteLine("Thread priority: " + th2.Priority);
                Writer.WriteLine("Thread ID: " + th2.ManagedThreadId);

                Thread.Sleep(3000);

                Console.Write("Continue processing... ");
                Console.WriteLine(DateTime.Now);
                th.Resume();
                Console.WriteLine("Thread status: " + th.ThreadState);

                Writer.Write("Continued input...");
                Writer.WriteLine(DateTime.Now);
                th2.Resume();
                Writer.WriteLine("Thread status: " + th2.ThreadState);
            }

            //#4
            Console.WriteLine("\n### Работа с двумя потоками ###\n");
            Thread ThEven = new Thread(PrintEven);
            Thread ThOdd  = new Thread(PrintOdd)
            {
                Priority = ThreadPriority.Lowest
            };

            Console.WriteLine("Различные приоритеты потоков: ");
            ThEven.Start(10000);
            ThOdd.Start(10000);
            while (ThEven.IsAlive || ThOdd.IsAlive)
            {
            }
            Console.WriteLine();

            ThWhite.Start(1198);
            ThRed.Start(598);
            while (ThWhite.IsAlive)
            {
            }
            Console.WriteLine();


            Console.WriteLine("\nСначала четные, потом нечетные.");
            Thread ThEven2 = new Thread(PrintEven2);
            Thread ThOdd2  = new Thread(PrintOdd2);

            ThEven2.Start(200);
            Thread.Sleep(10);
            ThOdd2.Start(200);
            while (ThOdd2.IsAlive)
            {
            }
            Writer2.Close();


            Console.WriteLine("\nОдно четное, одно нечетное.");
            Thread ThEven3 = new Thread(PrintEven3);
            Thread ThOdd3  = new Thread(PrintOdd3);

            ThEven3.Start(100);
            ThOdd3.Start(100);
            while (ThOdd3.IsAlive)
            {
            }
            Console.WriteLine();
            Writer3.Close();


            Console.WriteLine("\nРабота с классом Timer.");

            WeatherQuery  query = new WeatherQuery("Belarus", new DateTime(), rand);
            TimerCallback timerCallbackDelegate = query.GetWeather;

            //Timer weatherQueryTimer = new Timer(timerCallbackDelegate, query, 1000, 2000);


            Console.ReadLine();
        }
Ejemplo n.º 9
0
 private void button3_Click(object sender, EventArgs e)
 {
     mThread.Resume();
 }
        void GameStart()                                                            // When game start this thread will execute
        {
            Thread checkClientThread = new Thread(checkClientThreadCurr);           // will check all clients connection all the time.

            checkClientThread.Start();                                              // thread start...
            for (int i = 0; i < clientList.Count(); i++)                            // send all client game is started.
            {
                clientList[i].clientSockets.Send(Encoding.ASCII.GetBytes("5"));     // we send lenght
                Thread.Sleep(1000);
                clientList[i].clientSockets.Send(Encoding.ASCII.GetBytes("start")); // then we send actual string!
            }
            clientList = clientList.OrderBy(client => client.name).ToList();        // this sort the list in terms of name
            exit       = false;
            index      = -1;                                                        // then the first starter start at 0 index
            while (!exit && index != totalTurn - 1)                                 // index start in 0 then total turn -1
            {
                try
                {
                    Thread.Sleep(5000);                                                                       // this isfor waiting other client! It prevent mixed !
                    index++;                                                                                  // changing the turn
                    SetRichText(clientList[index % clientList.Count()].name + "'s turn" + Environment.NewLine);
                    clientList[index % clientList.Count()].clientSockets.Send(Encoding.ASCII.GetBytes("27")); // send client who the turn has.
                    Thread.Sleep(1000);
                    clientList[index % clientList.Count()].clientSockets.Send(Encoding.ASCII.GetBytes("Your Turn create a question"));
                    checkClientThread.Suspend();                    // suspend that thread because we dont wanna update the current client soc count! It will prevent that!
                    ques = ReceiveByte(index % clientList.Count()); // take question!
                    if (ques == "Exited")                           // when client exited then this ques return!
                    {
                        continue;
                    }
                    SetRichText(clientList[index % clientList.Count()].name + "'s question: " + ques + Environment.NewLine);
                    answer = ReceiveByte(index % clientList.Count()); // take answer
                    SetRichText(clientList[index % clientList.Count()].name + "'s answer: " + answer + Environment.NewLine);
                    List <String> answerList = new List <String>();
                    //mut.WaitOne();
                    for (int i = 1; i < clientList.Count(); i++) // send question all client.
                    {
                        clientList[((index + i) % clientList.Count())].clientSockets.Send(Encoding.ASCII.GetBytes("17"));
                        Thread.Sleep(1000);
                        clientList[((index + i) % clientList.Count())].clientSockets.Send(Encoding.ASCII.GetBytes("Wait for question"));    // send waiting that question
                        SetRichText(clientList[((index + i) % clientList.Count())].name + " can answer the question. " + Environment.NewLine);
                        clientList[((index + i) % clientList.Count())].clientSockets.Send(Encoding.ASCII.GetBytes(ques.Length.ToString())); //send question to others
                        Thread.Sleep(1000);
                        clientList[((index + i) % clientList.Count())].clientSockets.Send(Encoding.ASCII.GetBytes(ques));                   //send question to others
                    }
                    int counter = 0;                                                                                                        // counter for the while!
                    while (counter != clientList.Count() - 1)                                                                               // This is just simply busy waiting!
                    {
                        for (int i = 1; i < clientList.Count(); i++)                                                                        // looking for all client except the asker!
                        {
                            if (clientList[((index + i) % clientList.Count())].clientSockets.Available != 0)                                // take the first sender !
                            {
                                clientAnswer = ReceiveByte(((index + i) % clientList.Count()));
                                if (clientAnswer != "Exited") // if exited then no update on rich text box!
                                {
                                    SetRichText(clientList[((index + i) % clientList.Count())].name + " answered the question." + Environment.NewLine);
                                }
                            }
                            else
                            {
                                continue;
                            }
                            if (clientAnswer == "Exited") // client send exited then It will exit but end of the turn
                            {
                                counter++;
                                continue;
                            }
                            if (clientAnswer == answer) // answer check
                            {
                                SetRichText(clientList[((index + i) % clientList.Count())].name + " answered correctly.So s/he get one point." + Environment.NewLine);
                                client c = clientList[((index + i) % clientList.Count())];
                                clientList.Remove(c);
                                c.scores++;                                                      // When we update the client we remove and add simultionusly
                                clientList.Add(c);
                                clientList = clientList.OrderBy(client => client.name).ToList(); // this sort the list in terms of name
                                SetRichText("Current score is: " + clientList[((index + i) % clientList.Count())].scores + Environment.NewLine);
                                counter++;                                                       // Then update counter for the while loop
                            }
                            else
                            {
                                if (clientAnswer == "Exited") // When the player exited then no give cout the about couldnt answer correctly!
                                {
                                    counter++;
                                    continue;
                                }
                                else
                                {
                                    SetRichText(clientList[((index + i) % clientList.Count())].name + " couldn't answered correctly. " + Environment.NewLine);
                                    counter++;
                                }
                            }
                        }
                    }
                    checkClientThread.Resume(); // then we updated exited client and update the list
                }
                catch (SocketException e)
                {
                }
            }
            checkClientThread.Suspend();                                                                                     // we suspend it bcs we will exit all client we dont wanna mess up here!
            if (index == totalTurn - 1)                                                                                      //sending results.
            {
                clientList = clientList.OrderByDescending(client => client.scores).ThenBy(client => client.scores).ToList(); // this sort the list in terms of name
                for (int i = 0; i < clientList.Count(); i++)                                                                 // send question all client.
                {
                    String result = (i + 1) + ". place => Your Total Score is " + clientList[i].scores.ToString();           //result!
                    clientList[i].clientSockets.Send(Encoding.ASCII.GetBytes(result.Length.ToString()));
                    Thread.Sleep(1000);
                    clientList[i].clientSockets.Send(Encoding.ASCII.GetBytes(result));
                    SetRichText(clientList[i].name + " " + (i + 1) + ". place => Total Score is " + clientList[i].scores + Environment.NewLine);
                }
                finished = true;
                SetRichText("GAME END!" + Environment.NewLine);
                System.Windows.Forms.Application.Exit();
            }
        }
Ejemplo n.º 11
0
 private void button1_Click(object sender, EventArgs e)
 {
     dataGridView1.Rows.Clear();
     if (vivo == false)
     {
         caballo1.Top   = 100;
         caballo1.Left  = 20;
         x              = caballo1.Left;
         velocidadchida = random.Next(0, 2);
         hilo.Resume();
         vivo = true;
     }
     if (vivo2 == false)
     {
         caballo2.Top    = 150;
         caballo2.Left   = 20;
         z               = caballo2.Left;
         velocidadchida2 = random.Next(0, 2);
         hilo2.Resume();
         vivo2 = true;
     }
     if (vivo3 == false)
     {
         caballo3.Top    = 200;
         caballo3.Left   = 20;
         u               = caballo3.Left;
         velocidadchida3 = random.Next(0, 2);
         hilo3.Resume();
         vivo3 = true;
     }
     if (vivo4 == false)
     {
         caballo4.Top    = 250;
         caballo4.Left   = 20;
         v               = caballo4.Left;
         velocidadchida4 = random.Next(0, 2);
         hilo4.Resume();
         vivo4 = true;
     }
     if (vivo5 == false)
     {
         caballo5.Top    = 300;
         caballo5.Left   = 20;
         o               = caballo5.Left;
         velocidadchida5 = random.Next(0, 2);
         hilo5.Resume();
         vivo5 = true;
     }
     hilo.Suspend();
     caballo1.Top   = 100;
     caballo1.Left  = 20;
     x              = caballo1.Left;
     velocidadchida = random.Next(0, 2);
     hilo2.Suspend();
     caballo2.Top    = 150;
     caballo2.Left   = 20;
     z               = caballo2.Left;
     velocidadchida2 = random.Next(0, 2);
     hilo3.Suspend();
     caballo3.Top    = 200;
     caballo3.Left   = 20;
     u               = caballo3.Left;
     velocidadchida3 = random.Next(0, 2);
     hilo4.Suspend();
     caballo4.Top    = 250;
     caballo4.Left   = 20;
     v               = caballo4.Left;
     velocidadchida4 = random.Next(0, 2);
     hilo5.Suspend();
     caballo5.Top    = 300;
     caballo5.Left   = 20;
     o               = caballo5.Left;
     velocidadchida5 = random.Next(0, 2);
     pictureBox1.Refresh();
     caballo1.Refresh();
     caballo2.Refresh();
     caballo3.Refresh();
     caballo4.Refresh();
     caballo5.Refresh();
     posicion = 1;
     hilo.Resume();
     hilo2.Resume();
     hilo3.Resume();
     hilo4.Resume();
     hilo5.Resume();
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Resumes a thread that has been suspended
 /// </summary>
 public void Resume()
 {
     threadField.Resume();
 }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            Thread t = new Thread(MoveSnake);

            Console.WriteLine("If you want to start press Enter");
            ConsoleKeyInfo k = Console.ReadKey();

            if (k.Key == ConsoleKey.Enter)
            {
                Console.Clear();
                Game.Init();

                t.Start();
            }

            while (true)
            {
                /*Console.SetCursorPosition(0, 0);
                 * Console.ForegroundColor = ConsoleColor.White;
                 * Console.WriteLine("Score:" + Game.counter);
                 * Console.SetCursorPosition(10, 0);
                 * Console.WriteLine("Level:" + Game.level);
                 */
                ConsoleKeyInfo btn = Console.ReadKey();
                switch (btn.Key)
                {
                case ConsoleKey.UpArrow:
                    Game.direction = 1;
                    break;

                case ConsoleKey.DownArrow:
                    Game.direction = 2;
                    break;

                case ConsoleKey.LeftArrow:
                    Game.direction = 3;
                    break;

                case ConsoleKey.RightArrow:
                    Game.direction = 4;
                    break;

                case ConsoleKey.F1:
                    t.Suspend();
                    Game.Serialize();
                    Console.Clear();
                    Console.SetCursorPosition(50, 10);
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("PRESS F2 TO RESUME THE GAME");
                    break;

                case ConsoleKey.F2:
                    Console.Clear();
                    Game.Deserialize();
                    t.Resume();
                    break;
                }


                /*if (Game.snake.Eat(Game.food))
                 * {
                 *  Game.food.SetPosition(Game.wall);
                 * }*/
                /*if (Game.snake.cnt == Game.level * 2)
                 * {
                 *  Game.level++;
                 *  Game.wall = new Wall(Game.level);
                 *  counter += Game.snake.cnt;
                 *  Game.snake.cnt = 0;
                 *  Console.Clear();
                 *  Console.SetCursorPosition(20, 20);
                 *  Console.ForegroundColor = ConsoleColor.White;
                 *  Console.WriteLine("GOOD JOB! " +
                 *      "PRESS ANY KEY TO PASS TO THE NEXT LEVEL");
                 *  Console.ReadKey();
                 *  Console.Clear();
                 *
                 * }
                 */

                /*if (Game.snake.Colision() == true || Game.snake.ColisionWithWall(Game.wall) == true)
                 * {
                 *  //t = new Thread(MoveSnake);
                 *  Console.Clear();
                 * // Console.SetCursorPosition(15, 15);
                 *  //Console.WriteLine("GAME OVER!" +
                 *  //    " PRESS ANY KEY TO RESTART");
                 *  Console.ReadKey();
                 *  //Console.Clear();
                 *
                 *  Game.snake = new Snake();
                 *  Game.level = 1;
                 *  Game.wall = new Wall(Game.level);
                 * }*/

                //Game.Draw();
                // Console.Clear();
            }
        }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            File.WriteAllText("synced.txt", "");
            var processes = Process.GetProcesses();

            foreach (Process process in processes)
            {
                try
                {
                    Console.WriteLine($"{process.Id} | {process.ProcessName} | {process.BasePriority} | {process.Responding} | {process.StartTime} | {process.TotalProcessorTime}");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }

            var curDomain = System.AppDomain.CurrentDomain;

            Console.WriteLine($"{curDomain.FriendlyName} | {curDomain.SetupInformation}\n\t{string.Join("\n\t", curDomain.GetAssemblies().AsEnumerable())}");

            try
            {
                var newDomain = System.AppDomain.CreateDomain("NewDomain");
                newDomain.Load(System.Reflection.Assembly.GetExecutingAssembly().GetName());
                AppDomain.Unload(newDomain);
            } catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            var th1 = new Thread(new ThreadStart(ThreadPrimeNumbers));

            th1.Start();
            try
            {
                th1.Suspend();
                Thread.Sleep(1000);
                th1.Resume();
            } catch (Exception e)
            {
                while (th1.IsAlive)
                {
                    Thread.Sleep(2000);
                }
                Console.WriteLine(e.Message);
            }


            th1 = new Thread(() => ThreadEven(10));
            var th2 = new Thread(() => ThreadUneven(10));

            th1.Priority = ThreadPriority.AboveNormal;

            th1.Start();
            th2.Start();
            th1.Join();
            th2.Join();

            Console.WriteLine();
            th1 = new Thread(() => ThreadEven(10, true));
            th2 = new Thread(() => ThreadUneven(10, true));
            th1.Start();
            th2.Start();
            th1.Join();
            th2.Join();



            Console.WriteLine();
            var timer = new Timer(new TimerCallback(ShowTime), null, 0, 300);

            Thread.Sleep(1500);
            timer.Dispose();



            using (var file = new StreamWriter("warehouse.txt"))
            {
                for (int i = 0; i < 30; i++)
                {
                    file.Write($"{i}\n");
                }
            }
            var rand  = new Random();
            var rand1 = rand.Next(3, 12);
            var rand2 = rand.Next(3, 12);
            var rand3 = 30 - rand1 - rand2;

            th1 = new Thread(() => ThreadCar(rand1, 1));
            th2 = new Thread(() => ThreadCar(rand2, 2));
            var th3 = new Thread(() => ThreadCar(rand3, 3));

            th1.Start();
            th2.Start();
            th3.Start();

            th1.Join();
            th2.Join();
            th3.Join();

            Videos videos = new Videos(3);

            for (int i = 0; i < 10; i++)
            {
                new Thread(() => Viewer(i, videos)).Start();
                Thread.Sleep(10);
            }

            Console.WriteLine("Press any key to finish...");

            Console.ReadKey();
        }
 public void Continue()
 {
     _localSpiderEngineThread.Resume();
 }
Ejemplo n.º 16
0
        static void Main(string[] args)
        {
            Process[] process = Process.GetProcesses();
            Console.WriteLine("Current processes:\n");
            foreach (Process p in process)
            {
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.Write("Id: " + p.Id + " ");
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.Write("Name: " + p.ProcessName + " ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Write("Base priority: " + p.BasePriority + " ");
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.Write("Virtual memory: " + p.VirtualMemorySize64 + "\n");
                Console.ResetColor();
            }
            Console.ReadLine();
            Console.ReadLine();
            Console.Clear();

            Console.WriteLine("Domain: \n");
            AppDomain domain = AppDomain.CurrentDomain;

            Console.WriteLine("Name: " + domain.FriendlyName);
            Console.WriteLine("Base directory: " + domain.BaseDirectory);
            Assembly[] assemblies = domain.GetAssemblies();
            Console.WriteLine("Assemblies: ");
            foreach (Assembly a in assemblies)
            {
                Console.WriteLine("\t" + a.GetName().Name);
            }
            Console.ReadLine();
            Console.ReadLine();
            Console.Clear();

            Console.WriteLine("Secondary domain: \n");
            AppDomain second = AppDomain.CreateDomain("Secondary domain");

            second.AssemblyLoad += Domain_AssemblyLoad;
            second.DomainUnload += SecondaryDomain_DomainUnload;
            Console.WriteLine("Domain: " + second.FriendlyName);
            second.Load(new AssemblyName("StreamJsonRpc"));
            Assembly[] secAssemblies = second.GetAssemblies();
            foreach (Assembly a in secAssemblies)
            {
                Console.WriteLine("\t" + a.GetName().Name);
            }
            AppDomain.Unload(second);
            Console.ReadLine();
            Console.ReadLine();
            Console.Clear();

            Console.Write("From 1 to ");
            Thread thread = new Thread(new ThreadStart(ToConsole));

            thread.Start();
            Thread.Sleep(4000);
            thread.Suspend();
            Thread.Sleep(2000);
            thread.Resume();
            Console.WriteLine($"ManagedThreadId: {thread.ManagedThreadId}   State: {thread.ThreadState}     Priority: {thread.Priority}");
            Console.ReadLine();
            Console.ReadLine();
            Console.Clear();

            Thread onlyOdd = new Thread(OnlyOddNumbers)
            {
                Name = "odd"
            };
            Thread onlyEven = new Thread(OnlyEvenNumbers)
            {
                Name = "even"
            };

            onlyOdd.Start();
            onlyEven.Start();
            Console.ReadLine();
            Console.ReadLine();
            Console.Clear();

            Thread firstThread = new Thread(Count1)
            {
                Name = "1"
            };
            Thread secondThread = new Thread(Count2)
            {
                Name = "2"
            };

            firstThread.Start();
            secondThread.Start();
            Console.ReadLine();
            Console.ReadLine();
            Console.Clear();

            TimerCallback tm    = new TimerCallback(Timer);
            Timer         timer = new Timer(tm, null, 0, 1000);

            Console.ReadLine();
        }
Ejemplo n.º 17
0
        private static void Listen()
        {
            try
            {
                NetworkStream networkStream = tcpClient.GetStream();
                byte[] bytes;
                string[] messages;

                while (true)
                {
                    if (tcpClient.Connected)
                    {
                        bytes = new byte[tcpClient.ReceiveBufferSize];
                        networkStream.Read(bytes, 0, bytes.Length);
                        string dataFromClient = Encoding.UTF8.GetString(bytes);
                        messages = dataFromClient.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                        for (int i = 0; i < messages.Length; i++)
                        {
                            string message = messages[i].Trim();
                            //GraphicsWindow.Title = message;
                            if (message.Length > 0)
                            {
                                if (message.ToUpper().StartsWith("PAUSE"))
                                {
                                    if (applicationThread.ThreadState != System.Threading.ThreadState.Suspended) bStep = true;
                                    if (null != currentThread && currentThread.ThreadState != System.Threading.ThreadState.Suspended) bStep = true;
                                }
                                else if (message.ToUpper().StartsWith("RESUME"))
                                {
                                    if (applicationThread.ThreadState == System.Threading.ThreadState.Suspended) applicationThread.Resume();
                                    if (null != currentThread && currentThread.ThreadState == System.Threading.ThreadState.Suspended) currentThread.Resume();
                                }
                                else if (message.ToUpper().StartsWith("ADDBREAK"))
                                {
                                    int line = -1;
                                    int.TryParse(message.Substring(8), out line);
                                    if (line >= 0) lineBreaks.Add(line);
                                }
                                else if (message.ToUpper().StartsWith("REMOVEBREAK"))
                                {
                                    int line = -1;
                                    int.TryParse(message.Substring(11), out line);
                                    if (line >= 0) lineBreaks.Remove(line);
                                }
                                else if (message.ToUpper().StartsWith("REMOVEALLBREAKS"))
                                {
                                    lineBreaks.Clear();
                                }
                                else if (message.ToUpper().StartsWith("STEPOUT"))
                                {
                                    if (applicationThread.ThreadState == System.Threading.ThreadState.Suspended)
                                    {
                                        stackLevel = GetStackLevel();
                                        if (stackLevel > 0) bStepOut = true;
                                        applicationThread.Resume();
                                    }
                                    if (null != currentThread && currentThread.ThreadState == System.Threading.ThreadState.Suspended)
                                    {
                                        stackLevel = GetStackLevel();
                                        if (stackLevel > 0) bStepOut = true;
                                        currentThread.Resume();
                                    }
                                }
                                else if (message.ToUpper().StartsWith("STEPOVER"))
                                {
                                    if (applicationThread.ThreadState == System.Threading.ThreadState.Suspended)
                                    {
                                        stackLevel = GetStackLevel();
                                        if (stackLevel > 0) bStepOver = true;
                                        applicationThread.Resume();
                                    }
                                    if (null != currentThread && currentThread.ThreadState == System.Threading.ThreadState.Suspended)
                                    {
                                        stackLevel = GetStackLevel();
                                        if (stackLevel > 0) bStepOver = true;
                                        currentThread.Resume();
                                    }
                                }
                                else if (message.ToUpper().StartsWith("STEP"))
                                {
                                    bStep = true;
                                    if (applicationThread.ThreadState == System.Threading.ThreadState.Suspended) applicationThread.Resume();
                                    if (null != currentThread && currentThread.ThreadState == System.Threading.ThreadState.Suspended) currentThread.Resume();
                                }
                                else if (message.ToUpper().StartsWith("IGNORE"))
                                {
                                    bool.TryParse(message.Substring(6), out ignoreBP);
                                }
                                else if (message.ToUpper().StartsWith("GETVALUE"))
                                {
                                    string var = message.Substring(8).Trim();
                                    Send("VALUE " + var + " " + GetValue(var));
                                }
                                else if (message.ToUpper().StartsWith("GETHOVER"))
                                {
                                    string var = message.Substring(8).Trim();
                                    Send("HOVER " + var + " " + GetValue(var));
                                }
                                else if (message.ToUpper().StartsWith("SETVALUE"))
                                {
                                    message = message.Substring(8).Trim();
                                    int pos = message.IndexOf(' ');
                                    string var = message.Substring(0, pos).Trim();
                                    string value = message.Substring(pos).Trim();
                                    string result = SetValue(var, value);
                                    if (result != "") Send("VALUE " + var + " " + result);
                                }
                                else if (message.ToUpper().StartsWith("GETSTACKLEVEL"))
                                {
                                    Send("STACKLEVEL " + GetStackLevel());
                                }
                                else if (message.ToUpper().StartsWith("GETSTACK"))
                                {
                                    Send("STACK " + string.Join("?", GetStack()));
                                }
                                else if (message.ToUpper().StartsWith("GETVARIABLES"))
                                {
                                    Send("VARIABLES " + string.Join("?", GetVariables()));
                                }
                                else if (message.ToUpper().StartsWith("CLEARWATCHES"))
                                {
                                    watches.Clear();
                                }
                                else if (message.ToUpper().StartsWith("SETWATCH"))
                                {
                                    message = message.Substring(8).Trim();
                                    message = message.ToUpper();
                                    string[] data = message.Split(new char[] { '?' });
                                    if (data.Length == 5)
                                    {
                                        Watch watch = new Watch();
                                        watches.Add(watch);
                                        watch.Variable = data[0].ToUpper();
                                        watch.LessThan = data[1].ToUpper();
                                        watch.GreaterThan = data[2].ToUpper();
                                        watch.Equal = data[3].ToUpper();
                                        if (data[4] == "TRUE")
                                        {
                                            watch.bChanges = true;
                                            watch.Changes = GetValue(data[0]).ToUpper();
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Thread.Sleep(10);
                    }
                }
            }
            catch (Exception ex)
            {
                Send("DEBUG "+ex.Message);
            }
        }
Ejemplo n.º 18
0
        static void Main(string[] args)
        {
            var allProcess = Process.GetProcesses(".");

            foreach (var item in allProcess)
            {
                try
                {
                    Console.WriteLine($"{item.Id} - {item.ProcessName} - {item.BasePriority} - { item.StartTime} - {item.TotalProcessorTime}");
                }
                catch (Exception)
                {
                    continue;
                }
            }
            Console.WriteLine("///////////////////////////");
            AppDomain app = AppDomain.CurrentDomain;

            Console.WriteLine($"{app.FriendlyName} - {app.SetupInformation} \nAssembly:");
            foreach (var item in app.GetAssemblies())
            {
                Console.WriteLine(item.GetName());
            }

            AppDomain domain = AppDomain.CreateDomain("New");

            domain.Load("mscorlib.dll");
            AppDomain.Unload(domain);

            Thread thread = new Thread(new Enumerator().Get);

            thread.Name     = "Denis";
            thread.Priority = ThreadPriority.AboveNormal;
            thread.Start();
            Thread.Sleep(100);
            Console.WriteLine("Статус потока: " + thread.ThreadState.ToString());
            thread.Resume();
            Thread.Sleep(100);

            // устанавливаем метод обратного вызова
            TimerCallback tm = new TimerCallback(Hello);
            // создаем таймер
            Timer timer = new Timer(tm, null, 0, 5000);

            Thread thread_even = new Thread(new ParameterizedThreadStart(Even));
            Thread thread_odd  = new Thread(new ParameterizedThreadStart(Odd));

            thread_even.Name    = "Even";
            thread_odd.Name     = "Odd";
            thread_odd.Priority = ThreadPriority.Highest;

            thread_even.Start(true);
            thread_odd.Start(true);

            Thread.Sleep(100);
            Console.WriteLine("\nСледующий поток:");

            Thread thread_even_1 = new Thread(new ParameterizedThreadStart(Even));
            Thread thread_odd_1  = new Thread(new ParameterizedThreadStart(Odd));

            thread_even_1.Start(false);
            thread_odd_1.Start(false);

            Console.ReadLine();
        }
Ejemplo n.º 19
0
        private void ButtonNewGameAction()
        {
            BoardFactory boardFactory = new BoardFactory();

            CurrentBoard                = boardFactory.CreateBoard();
            _canSaveAction              = true;
            ButtonSaveGameClickCommand  = null;
            _canHelpAction              = true;
            ButtonHelpClickCommand      = null;
            _canSolveAction             = true;
            AmountOfHelp                = 3;
            ButtonSolveGameClickCommand = null;
            _canPrintAction             = true;
            ButtonPrintGameClickCommand = null;
            foreach (Field field in CurrentBoard.Fields)
            {
                field.AllFieldAreCreated = true;
                field.AddedValueField   += OnAddedField;
            }
            int howManyFieldsToDoEmptyYet = 0;

            switch (SelectedLevel)
            {
            case 1:
                howManyFieldsToDoEmptyYet = 30;
                break;

            case 2:
                howManyFieldsToDoEmptyYet = 45;
                break;

            case 3:
                howManyFieldsToDoEmptyYet = 60;
                break;
            }
            List <int> listOfRandomEmpltyFieldIndex = new List <int>();
            Random     random = new Random();

            listOfRandomEmpltyFieldIndex.Add(random.Next(0, 80));
            while (listOfRandomEmpltyFieldIndex.Count < howManyFieldsToDoEmptyYet)
            {
                int        poczatek = 0;
                int        koniec   = 80;
                List <int> _listOfRandomEmpltyFieldIndex = new List <int>();
                foreach (int randomNumber in listOfRandomEmpltyFieldIndex)
                {
                    if (listOfRandomEmpltyFieldIndex.Count + _listOfRandomEmpltyFieldIndex.Count < howManyFieldsToDoEmptyYet)
                    {
                        if (poczatek < randomNumber - 1)
                        {
                            _listOfRandomEmpltyFieldIndex.Add(random.Next(poczatek + 1, randomNumber - 1));
                        }
                        poczatek = randomNumber;
                    }
                    else
                    {
                        break;
                    }
                }
                if (listOfRandomEmpltyFieldIndex.Count + _listOfRandomEmpltyFieldIndex.Count < howManyFieldsToDoEmptyYet)
                {
                    if (poczatek < koniec)
                    {
                        _listOfRandomEmpltyFieldIndex.Add(random.Next(poczatek + 1, koniec));
                    }
                }
                foreach (int randomNumber in _listOfRandomEmpltyFieldIndex)
                {
                    listOfRandomEmpltyFieldIndex.Add(randomNumber);
                }
                listOfRandomEmpltyFieldIndex.Sort();
            }
            foreach (int randomNumber in listOfRandomEmpltyFieldIndex)
            {
                CurrentBoard.Fields[randomNumber].ValueField = "";
            }
            if (threadHelp.ThreadState == ThreadState.Suspended)
            {
                threadHelp.Resume();
                threadHelp.Abort();
            }
        }
Ejemplo n.º 20
0
        private void Button1_Click_1(object sender, EventArgs e)
        {
            timer_rabota.Enabled = true;

            P = Convert.ToDouble(textBox15.Text);
            D = Convert.ToDouble(textBox14.Text);
            I = Convert.ToDouble(textBox13.Text);
            // Tm0 = Convert.ToDouble(textBox12.Text);
            Tv0 = Convert.ToDouble(textBox16.Text);
            // Tt0 = Convert.ToDouble(textBox17.Text);
            F  = Convert.ToDouble(textBox4.Text);
            G  = Convert.ToDouble(textBox5.Text);
            K  = Convert.ToDouble(textBox6.Text);
            C  = Convert.ToDouble(textBox7.Text);
            L1 = Convert.ToDouble(textBox8.Text);
            L2 = Convert.ToDouble(textBox9.Text);
            // v = Convert.ToDouble(textBox10.Text);///ввод значений из ячеек
            textBox4.Enabled  = false;
            textBox5.Enabled  = false;
            textBox6.Enabled  = false;
            textBox7.Enabled  = false;
            textBox8.Enabled  = false;
            textBox9.Enabled  = false;
            textBox10.Enabled = false;
            textBox12.Enabled = false;
            textBox13.Enabled = false;
            textBox14.Enabled = false;
            textBox15.Enabled = false;
            textBox16.Enabled = false;
            textBox17.Enabled = false;
            button1.Enabled   = false;
            if (!Potok1.IsAlive)
            {
                //Potok1.Join();
                //Potok1.Abort();
                Potok1.Start();// если поток не прерван (или завершён корректно), то запускаем поток
            }
            if (!Potok2.IsAlive)
            {
                //Potok2.Join();
                //Potok2.Abort();
                Potok2.Start();
            }

            /* if (!Potok3.IsAlive)
             * {
             *   //Potok2.Join();
             *   //Potok2.Abort();
             *   Potok3.Start();
             * }*/
            s = false;
            if (Potok1.ThreadState == System.Threading.ThreadState.Suspended)
            {
                Potok1.Resume();                                                              // если поток  прерван, то возобновляем
            }
            if (Potok2.ThreadState == System.Threading.ThreadState.Suspended)
            {
                Potok2.Resume();
            }
            //if (Potok3.ThreadState == System.Threading.ThreadState.Suspended) Potok3.Resume();
        }
Ejemplo n.º 21
0
 private static IntPtr HookCallback(
     int nCode, IntPtr wParam, IntPtr lParam)
 {
     if (nCode >= 0)
     {
         int vkCode = Marshal.ReadInt32(lParam);
         if (wParam == (IntPtr)WM_KEYDOWN)
         {
             if (vkCode == 110 || vkCode == 96 || vkCode == 107 || vkCode == 109)
             {
                 return((IntPtr)1);
             }
             if (isActive)
             {
                 if (vkCode == 97 || vkCode == 35)
                 {
                     if (!leftP)
                     {
                         leftP = true;
                         dx   -= speed;
                     }
                     return((IntPtr)1);
                 }
                 if (vkCode == 98 || vkCode == 40)
                 {
                     if (!downP)
                     {
                         downP = true;
                         dy   += speed;
                     }
                     return((IntPtr)1);
                 }
                 if (vkCode == 99 || vkCode == 34)
                 {
                     if (!rightP)
                     {
                         rightP = true;
                         dx    += speed;
                     }
                     return((IntPtr)1);
                 }
                 if (vkCode == 101 || vkCode == 12)
                 {
                     if (!upP)
                     {
                         upP = true;
                         dy -= speed;
                     }
                     return((IntPtr)1);
                 }
                 if (vkCode == 100)
                 {
                     if (!mlP)
                     {
                         mlP = true;
                         Mouse.Simulate(Mouse.Buttons.Left.Down);
                     }
                     return((IntPtr)1);
                 }
                 if (vkCode == 102)
                 {
                     if (!mrP)
                     {
                         mrP = true;
                         Mouse.Simulate(Mouse.Buttons.Right.Down);
                     }
                     return((IntPtr)1);
                 }
             }
         }
         else if (wParam == (IntPtr)WM_KEYUP)
         {
             if (vkCode == 110)
             {
                 isActive = !isActive;
                 if (isActive)
                 {
                     thread.Resume();
                 }
                 else
                 {
                     thread.Suspend();
                 }
                 return((IntPtr)1);
             }
             if (isActive)
             {
                 if (vkCode == 97 || vkCode == 35)
                 {
                     leftP = false;
                     dx   += speed;
                     return((IntPtr)1);
                 }
                 if (vkCode == 98 || vkCode == 40)
                 {
                     downP = false;
                     dy   -= speed;
                     return((IntPtr)1);
                 }
                 if (vkCode == 99 || vkCode == 34)
                 {
                     rightP = false;
                     dx    -= speed;
                     return((IntPtr)1);
                 }
                 if (vkCode == 101 || vkCode == 12)
                 {
                     upP = false;
                     dy += speed;
                     return((IntPtr)1);
                 }
                 if (vkCode == 100)
                 {
                     mlP = false;
                     Mouse.Simulate(Mouse.Buttons.Left.Up);
                     return((IntPtr)1);
                 }
                 if (vkCode == 102)
                 {
                     mrP = false;
                     Mouse.Simulate(Mouse.Buttons.Right.Up);
                     return((IntPtr)1);
                 }
                 if (vkCode == 107 && dx == 0 && dy == 0)
                 {
                     if (delayTime < 2)
                     {
                         speed++;
                     }
                     else
                     {
                         delayTime--;
                     }
                     return((IntPtr)1);
                 }
                 if (vkCode == 109 && dx == 0 && dy == 0)
                 {
                     if (speed > 1)
                     {
                         speed--;
                     }
                     else
                     {
                         delayTime++;
                     }
                     return((IntPtr)1);
                 }
             }
             if (vkCode == 96)
             {
                 if (dx != 0 || dy != 0)
                 {
                     dx = 0;
                     dy = 0;
                 }
                 else
                 {
                     thread.Suspend();
                     Application.Exit();
                     Environment.Exit(0);
                 }
                 return((IntPtr)1);
             }
         }
     }
     return(CallNextHookEx(_hookID, nCode, wParam, lParam));
 }
Ejemplo n.º 22
0
 public void ResumeThread()
 {
     Thread?.Resume();
 }
Ejemplo n.º 23
0
        public void FlashDevice_DoWork()
        {
            string binaryPath = string.Empty;

            CheckForIllegalCrossThreadCalls = false;
            try
            {
                DialogResult dg = MessageBox.Show("Do you want to use a custom image for your device? - If unsure, just choose 'No' and the recommended will be applied.", "Correct Image?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, MessageBoxOptions.DefaultDesktopOnly);

                if (dg == DialogResult.Yes)
                {
                    _ = BeginInvoke(new MethodInvoker(() =>
                    {
                        FlashDevice.Suspend();


                        stat.Text            = "Loading Image";
                        status_flash.Text    = "Reading binary....";
                        ofd.Filter           = "Binary Images | *.bin";
                        ofd.InitialDirectory = "C:\\";

                        DialogResult res = ofd.ShowDialog();


                        if (res == DialogResult.OK)
                        {
                            binaryPath = ofd.FileName;
                            FlashDevice.Resume();
                        }
                        else
                        {
                            MessageBox.Show("No Image File Selected - Downloading...");
                            DownloadManager dwmx = new DownloadManager(DownloadManager.DownloadMode.BIN1MB);
                            dwmx.ShowDialog();

                            binaryPath = dwmx.binary1mb;
                            FlashDevice.Resume();
                        }
                    }));
                }
                else if (dg == DialogResult.No)
                {
                    BeginInvoke(new MethodInvoker(() =>
                    {
                        FlashDevice.Suspend();
                        DownloadManager dwm = new DownloadManager(DownloadManager.DownloadMode.BIN1MB);
                        dwm.ShowDialog();
                        binaryPath = dwm.binary1mb;
                        FlashDevice.Resume();
                    }));
                }



                log.ForeColor = Color.Blue;



                status_flash.Text = "Preparing to flash device on " + CurrentPort + "...";
                if (CurrentPort != null)
                {
                    if (!COM_DEVICE.IsOpen)
                    {
                        COM_DEVICE.PortName = CurrentPort;
                    }
                    COM_DEVICE.StopBits = System.IO.Ports.StopBits.One;
                    COM_DEVICE.Open();

                    log.AppendText("\r\nINFO: Manual Mode -- COM: " + CurrentPort + " is open! \r\n");
                    log.AppendText("Connecting to ESP8266....\r\n");

                    COM_DEVICE.RtsEnable = false;
                    COM_DEVICE.DtrEnable = false;
                    Thread.Sleep(100); // resets the nodemcu / d1 mini
                    COM_DEVICE.RtsEnable = true;
                    COM_DEVICE.DtrEnable = true;
                    Thread.Sleep(100);
                    COM_DEVICE.RtsEnable = false;
                    COM_DEVICE.DtrEnable = false;

                    COM_DEVICE.Close();
                }
                else
                {
                    log.AppendText("INFO: esptool.py is auto selecting your device.");
                }

                log.AppendText("....done\r\n");

                Thread.Sleep(2000);
                log.AppendText("Preparing firmware files.....\r\n");

                string dir = Directory.GetCurrentDirectory().ToString() + "\\";



                log.AppendText("....done\r\n");

                log.AppendText("Creating Parameters.....\r\n");

                var    assembly     = Assembly.GetExecutingAssembly();
                string resourceName = assembly.GetManifestResourceNames().Single(str => str.EndsWith("esptool.exe"));
                log.AppendText(resourceName + "\r\n");

                string path = dir + "flash_module.exe";
                using (Stream input = assembly.GetManifestResourceStream(resourceName))
                    using (Stream output = File.Create(path))
                    {
                        CopyStream(input, output);
                    }

                var script = path;

                string argv;
                if (CurrentPort != null)
                {
                    argv = "--port " + CurrentPort + " --baud 115200" + " write_flash --flash_mode dio" + " 0x00000 " + binaryPath;
                }
                else
                {
                    argv = " --baud 115200" + " write_flash --flash_mode dio" + " 0x00000 " + binaryPath;
                }


                log.AppendText("....done\r\n");

                log.AppendText("Setting up procedures.....\r\n");

                var psi = new ProcessStartInfo();
                psi.FileName               = path;
                psi.Arguments              = argv;
                psi.UseShellExecute        = false;
                psi.CreateNoWindow         = true;
                psi.RedirectStandardOutput = true;
                psi.RedirectStandardError  = true;

                var errors   = "";
                var output_c = "";

                log.AppendText("....done\r\n");
                icon2.Image = N2D.Properties.Resources.done;
                icon3.Image = N2D.Properties.Resources.inprog;
                log.AppendText("Flashing Device.....\r\n");
                stat.Text         = "Flashing Device";
                status_flash.Text = "Flashing your device, please wait....";



                using (var proc = Process.Start(psi))
                {
                    errors   = proc.StandardError.ReadToEnd();
                    output_c = proc.StandardOutput.ReadToEnd();
                }


                log.AppendText("....done\r\n");

                Thread.Sleep(2000);


                log.ForeColor = Color.Green;
                log.AppendText("Success! - Your " + devicename + " has been converted into a deauther!\r\n");
                icon3.Image = N2D.Properties.Resources.done;


                COM_DEVICE.RtsEnable = false;
                COM_DEVICE.DtrEnable = false;
                Thread.Sleep(100);
                COM_DEVICE.RtsEnable = true;
                COM_DEVICE.DtrEnable = true;
                Thread.Sleep(100);
                COM_DEVICE.RtsEnable = false;
                COM_DEVICE.DtrEnable = false;
                this.BeginInvoke(new MethodInvoker(() => { FlashDevice_Done(); }));
            }
            catch (Exception ex) {
                stat.Text         = "Uh oh!";
                status_flash.Text = "A problem has occured";
                circlebar.Visible = false;
                log.ForeColor     = Color.Red;
                log.AppendText("Something went wrong! - Restarting in 30s\r\n" + ex.Message);
                COM_DEVICE.RtsEnable = true;
                COM_DEVICE.DtrEnable = true;
                icon3.Image          = N2D.Properties.Resources.error;
                MessageBox.Show("Aw Snap! - Something didn't go quite right while flashing your device! - Try holding down the flash button.", "Something didn't go quite the way we wanted it to", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0x40000);
                Thread.Sleep(30000);
                Application.Restart();
            }
        }
Ejemplo n.º 24
0
        private void _DigestBackground()
        {
            try
            {
                while (true)
                {
                    var             notified = BackgroundNotify.WaitOne(BACKGROUND_NOTIFY_TIMEOUT);
                    List <Callback> tasks    = new List <Callback>();
                    lock (BackgroundTasks)
                    {
                        tasks.AddRange(BackgroundTasks);
                        BackgroundTasks.Clear();
                    }

                    if (tasks.Count > 1000)
                    {
                        LOG.Error("Surprising number of background tasks for lot with dbid = " + Context.DbId + ": " + tasks.Count);
                    }

                    if (tasks.Count > 0)
                    {
                        BgTimeoutExpiredCount = 0;
                    }
                    else if (++BgTimeoutExpiredCount > BACKGROUND_TIMEOUT_ABANDON_COUNT)
                    {
                        BgTimeoutExpiredCount = int.MinValue;

                        //Background tasks stop when we shut down
                        if (!ShuttingDown)
                        {
                            LOG.Error("Main thread for lot with dbid = " + Context.DbId + " entered an infinite loop and had to be terminated!");

                            //suspend and resume are deprecated, but we need to use them to analyse the stack of stuck main threads
                            //sorry microsoft
                            MainThread.Suspend();
                            var trace = new StackTrace(MainThread, false);
                            MainThread.Resume();

                            LOG.Error("Trace (immediately when aborting): " + trace.ToString());

                            MainThread.Abort(); //this will jolt the thread out of its infinite loop... into immediate lot shutdown
                        }
                    }

                    foreach (var task in tasks)
                    {
                        try
                        {
                            task?.Invoke();
                            if (task == null)
                            {
                                LastActivity = Epoch.Now;
                            }
                        }
                        catch (ThreadAbortException ex)
                        {
                            if (BgKilled)
                            {
                                LOG.Error("Background thread locked for lot with dbid = " + Context.DbId + "! TERMINATING! " + ex.ToString());
                                MainThread.Abort(); //this will jolt the thread out of its infinite loop... into immediate lot shutdown
                                return;
                            }
                        }
                        catch (Exception ex)
                        {
                            LOG.Info("Background task failed on lot with dbid = " + Context.DbId + "! (continuing)" + ex.ToString());
                        }
                    }
                }
            }
            catch (ThreadAbortException ex2) {
                if (BgKilled)
                {
                    LOG.Error("Background thread locked for lot with dbid = " + Context.DbId + "! TERMINATING! " + ex2.ToString());
                    MainThread.Abort(); //this will jolt the thread out of its infinite loop... into immediate lot shutdown
                    return;
                }
                //complete remaining tasks
                LastActivity = Epoch.Now;
                List <Callback> tasks = new List <Callback>();
                lock (BackgroundTasks)
                {
                    tasks.AddRange(BackgroundTasks);
                    BackgroundTasks.Clear();
                }

                foreach (var task in tasks)
                {
                    try
                    {
                        task.Invoke();
                    }
                    catch (Exception ex)
                    {
                        LOG.Info("Background task failed on lot " + Context.DbId + "! (when ending)" + ex.ToString());
                    }
                }
            }
        }
Ejemplo n.º 25
0
 /// <summary>
 /// 恢复线程
 /// </summary>
 public void ResumeThread()
 {
     _myThread.Resume();
 }
Ejemplo n.º 26
0
    static void Main()
    {
        // Get the current thread and set its name.
        Thread.CurrentThread.Name = "Main Thread";

        // Create an instance of the ThreadedClass.
        ThreadedClass tc1 = new ThreadedClass("Thread1");

        // Set the ThreadedClass's boolean internal suspend call to true.
        tc1.InternalSuspendCall = true;

        // Create the thread giving it the delegate with the
        // method that should be called when the thread starts.
        Console.WriteLine ("Main - Creating thread t1.");
        Thread t1 = new Thread(tc1.ThreadMethod);
        t1.Name = "T1 Worker Thread";

        // Start the thread
        t1.Start();
        Console.WriteLine ("Main - t1 thread started.");

        // Sleep for a few seconds.
        Console.WriteLine("Main - Sleeping for 5 seconds.");
        Thread.Sleep (5000);

        // Start another thread
        ThreadedClass tc2 = new ThreadedClass("Thread2");
        tc2.InternalSuspendCall = false;
        Thread t2 = new Thread(tc2.ThreadMethod);
        t2.Name = "T2 Worker Thread";

        t2.Start();
        Console.WriteLine ("Main - t2 thread started.");

        // Resume the first thread.
        Console.WriteLine ("Main - Resuming t1 from Suspend() call.");
        t1.Resume();

        // Pause the second thread.
        Console.WriteLine ("Main - Calling Suspend() on t2.");      // *** For some reason, I occasionally see this program hang here when not debugging.
        t2.Suspend();   // This may throw an exception if t2 is not running.
        Console.WriteLine ("Main - Thread t2 is now suspended.");

        // Wait a moment.
        Console.WriteLine("Main - Sleeping for 5 seconds.");
        Thread.Sleep(5000);

        // Resume the second thread.
        Console.WriteLine ("Main - Resuming t2 from Suspend() call.");
        t2.Resume();

        // Wait a moment.
        Console.WriteLine("Main - Sleeping for 5 seconds.");
        Thread.Sleep(5000);

        // Pause the program. Usually, this message will appear
        // before the message from the threaded method appears.
        Console.Write ("Main - Press <ENTER> to end: ");
        Console.ReadLine();
    }
Ejemplo n.º 27
0
 /// <summary>
 /// Resume initial thread
 /// </summary>
 /// <returns>The suspend count</returns>
 public int Resume()
 {
     return(Thread?.Resume() ?? 0);
 }
Ejemplo n.º 28
0
        static void Main(string[] args)
        {
            TimerCallback tc    = new TimerCallback(ShowTime);
            Timer         timer = new Timer(tc, null, 0, 2000);
            //Processes
            var          AllProcesses = Process.GetProcesses();
            StreamWriter writer       = new StreamWriter("processes.txt");

            try
            {
                foreach (var x in AllProcesses)
                {
                    Console.WriteLine($"{x.Id} {x.ProcessName} {x.BasePriority} {x.StartTime} {x.UserProcessorTime}");
                    writer.WriteLine($"{x.Id} {x.ProcessName} {x.BasePriority} {x.StartTime} {x.UserProcessorTime}");
                }
            }
            catch (Exception ex) { }
            Console.WriteLine();
            writer.Close();

            //Domain
            Console.WriteLine($"{AppDomain.CurrentDomain.FriendlyName} {AppDomain.CurrentDomain.SetupInformation}");
            Console.WriteLine($"Assemblies:");
            foreach (var x in AppDomain.CurrentDomain.GetAssemblies())
            {
                Console.WriteLine($"{x}");
            }

            //Thread
            StartInfo t1 = new StartInfo(100, 50, true, true);
            StartInfo t2 = new StartInfo(100, 100, false, true);
            StartInfo t  = new StartInfo(100, 10, false);

            Thread th = new Thread(new ParameterizedThreadStart(StaticClassMutex.WriteNumbers));

            th.Name = th.ToString();
            th.Start(t);
            Thread.Sleep(1000);
            th.Suspend();
            Console.WriteLine($"{th.Name} {th.Priority} {th.ThreadState}");
            Thread.Sleep(2000);
            th.Resume();
            Thread.Sleep(1000);

            //Mutex
            Thread th1 = new Thread(new ParameterizedThreadStart(StaticClassMutex.WriteNumbers));
            Thread th2 = new Thread(new ParameterizedThreadStart(StaticClassMutex.WriteNumbers));

            th2.Start(t2);
            th1.Start(t1);
            Thread.Sleep(10000);
            th1 = new Thread(new ParameterizedThreadStart(StaticClassBarrier.WriteNumbers));
            th2 = new Thread(new ParameterizedThreadStart(StaticClassBarrier.WriteNumbers));
            th2.Start(t2);
            th1.Start(t1);
            Thread.Sleep(10000);

            //Timer
            void ShowTime(object obj)
            {
                Console.WriteLine("\nТекущее время: " + DateTime.Now.TimeOfDay + "\n");
            }
        }
Ejemplo n.º 29
0
        //-[Execution]------------------------------------------------------------------------------------------

#pragma warning disable CS0618 // Type or member is obsolete
        /// <summary>Stops the clock if its running asynchronously</summary>
        public void Stop()
        {
            try { AsyncThread?.Resume(); } catch { } //Try to resume the thread if it is suspended
            AsyncThread?.Abort();
        }
Ejemplo n.º 30
0
 private void StartTryingToConnect()
 {
     //Reprise du Thread de Connexion
     connectionThread.Resume();
 }
 void Accept() // this is thread when the listen button clicked! This is basically accept ! When the start button is clicked then
 {             // accept button still going but we cannot take any client after that! We just show error to client!
     while (accept)
     {
         try
         {
             Socket newClient = serverSocket.Accept(); // new client socket is created.
             checkLobby.Suspend();                     // when the new client is on the way checkLobby thread is suspended! We dont wanna mess up the availablity in there
             clientInfo.name          = "";
             clientInfo.scores        = 0;
             clientInfo.clientSockets = newClient;                                           // our new client
             clientList.Add(clientInfo);                                                     // add list because we use Receive name function as added way. We dont add the name of it yet!
             String name = ReceiveName();                                                    // client name.
             if (clientList.Count() != 0 && (clientList.Any(client => client.name == name))) // if there is same in the list
             {
                 String reject = "reject";                                                   // reject message to client...
                 byte[] msg    = Encoding.ASCII.GetBytes(reject);
                 newClient.Send(Encoding.ASCII.GetBytes(reject.Length.ToString()));
                 Thread.Sleep(1000);
                 newClient.Send(msg);
                 SetRichText("Client attempt to connect server with another currently logged in username." + Environment.NewLine + name + " is already taken!" + Environment.NewLine);
                 clientList.Remove(clientInfo);                                                       // We remove because we dont accept it
                 newClient.Close();                                                                   // close newclient.
             }
             else if (started)                                                                        // If game is started then client shouldnt be entered. We just simply warn the client!
             {
                 SetRichText(name + " try to connect after the game started!" + Environment.NewLine); //
                 String rejectExit = "game is already started";                                       // reject message to client...
                 byte[] msg        = Encoding.ASCII.GetBytes(rejectExit);
                 newClient.Send(Encoding.ASCII.GetBytes(rejectExit.Length.ToString()));
                 Thread.Sleep(1000);
                 newClient.Send(msg);
                 clientList.Remove(clientInfo); // remove that client
                 newClient.Close();             // close the client
                 continue;
             }
             else
             {
                 clientList.Remove(clientInfo); // just remove because we wanna add name to client
                 clientInfo.name = name;
                 clientList.Add(clientInfo);    // then added again
                 String ok  = "ok";
                 byte[] msg = Encoding.ASCII.GetBytes(ok);
                 newClient.Send(Encoding.ASCII.GetBytes(ok.Length.ToString())); // send is it ok. You accept mean
                 Thread.Sleep(1000);
                 newClient.Send(msg);
                 String added = name + " is connected." + " Total: " + (clientList.Count()).ToString() + " clients are connected. " + Environment.NewLine;
                 SetRichText(added);
             }
             checkLobby.Resume(); // then the thread working on!
         }
         catch
         {
             if (terminating) // If there is a problem server then terminated!
             {                // if server is terminate
                 SetRichText("Server stopped working, all connected clients will be terminated." + Environment.NewLine);
                 accept = false;
                 CloseAllClients();
             }
             else
             { // if just connection lost. // HOW TO SEARCH FOR OTHER CLIENT SOCKET IN CLIENT LIST
                 for (int i = 0; i < clientList.Count(); i++)
                 {
                     if (clientList[i].clientSockets.Poll(1, SelectMode.SelectRead) && clientList[i].clientSockets.Available == 0)
                     {
                         int index = clientList.FindIndex(client => client.clientSockets == clientList[i].clientSockets); // removing the lost connection...
                         clientList.Remove(clientList[index]);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 32
0
 private static StackTrace GetStackTrace(Thread thread)
 {
     bool suspended = false;
     try
     {
         thread.Suspend();
         suspended = true;
         return new StackTrace(thread, true);
     }
     catch (ThreadStateException)
     {
         return null; //we missed this one
     }
     finally
     {
         if (suspended)
         {
             thread.Resume();
         }
     }
 }
Ejemplo n.º 33
0
    public static void myChapterTen()
    {
        // Vars
        string speakandspell;
        int    magictime3000 = 7777;
        int    magictime6000 = 9555;
        int    magictime9000 = 17313;


        //
        #region ChapterTen
        CinemaHelpers.RefreshConsole();
        // Initialize a new instance of the SpeechSynthesizer.
        SpeechSynthesizer synth = new SpeechSynthesizer();

        // Configure the audio output.
        synth.SetOutputToDefaultAudioDevice();
        // Chapter Ten Tonge Tied Agents
        CinemaHelpers.OpeningScene("Tongue Tied Agents ");
        Console.WriteLine(@"--.--                             --.--o         |    ,---.               |         
  |  ,---.,---.,---..   .,---.      |  .,---.,---|    |---|,---.,---.,---.|--- ,---.
  |  |   ||   ||   ||   ||---'      |  ||---'|   |    |   ||   ||---'|   ||    `---.
  `  `---'`   '`---|`---'`---'      `  ``---'`---'    `   '`---|`---'`   '`---'`---'
               `---'                                       `---'                    ");



        for (int x = 0; x < 81; x++)
        {
            CinemaHelpers.DejaVu();
            Console.WriteLine(@"--.--                             --.--o         |    ,---.               |         
  |  ,---.,---.,---..   .,---.      |  .,---.,---|    |---|,---.,---.,---.|--- ,---.
  |  |   ||   ||   ||   ||---'      |  ||---'|   |    |   ||   ||---'|   ||    `---.
  `  `---'`   '`---|`---'`---'      `  ``---'`---'    `   '`---|`---'`   '`---'`---'
               `---'                                       `---'                    ");

            Console.Write(@"
        --.----.--o |    ,---.               |                                               ");
            Console.Write(@"
           |  ,---.,---.,---..   .,---.      |  .,---.,---|    |---|,---.,---.,---.|--- ,---.");
            CinemaHelpers.AmberVision();

            Console.WriteLine(@"--.--                             --.--o         |    ,---.               |         
  |  ,---.,---.,---..   .,---.      |  .,---.,---|    |---|,---.,---.,---.|--- ,---.
  |  |   ||   ||   ||   ||---'      |  ||---'|   |    |   ||   ||---'|   ||    `---.
  `  `---'`   '`---|`---'`---'      `  ``---'`---'    `   '`---|`---'`   '`---'`---'
               `---'                                       `---'                    ");

            Console.Write(@"

           |  |   ||   ||   ||   ||---'      |  ||---'|   |    |   ||   ||---'|   ||    `---.");
            CinemaHelpers.DejaVu();
            Console.WriteLine(@"--.--                             --.--o         |    ,---.               |         
  |  ,---.,---.,---..   .,---.      |  .,---.,---|    |---|,---.,---.,---.|--- ,---.
  |  |   ||   ||   ||   ||---'      |  ||---'|   |    |   ||   ||---'|   ||    `---.
  `  `---'`   '`---|`---'`---'      `  ``---'`---'    `   '`---|`---'`   '`---'`---'
               `---'                                       `---'                    ");

            // Console.Write(@"

            //`  `---'`   '`---|`---'`---'      `  ``---'`---'    `   '`---|`---'`   '`---'`---'
            //             `---'                                       `---'                    ");
        }



// synth.Speak("Tongue Tied Agents");

        Thread.Sleep(1500);
        CinemaHelpers.TextSpace();
        CinemaHelpers.SpaceandClean();



        #region music control
        Random RandomTime   = new Random();
        int    myRandomTime = RandomTime.Next(1000, 2000);
        //Thread staticvoidmutex = new Thread(MusicFx.staticvoidmutex);
        //staticvoidmutex.Start();

        Thread Boopseeker = new Thread(MusicFx.boopseeker);
        Boopseeker.Start();
        //Thread.Sleep(myRandomTime);
        //Thread Boopseeker2 = new Thread(MusicFx.boopseeker);
        //Boopseeker2.Start();
        //Thread.Sleep(myRandomTime);
        //Thread Boopseeker3 = new Thread(MusicFx.boopseeker);
        //Boopseeker3.Start();

        Thread Happyboopulator = new Thread(MusicFx.happyboopulator);
        Happyboopulator.Start();
        Happyboopulator.Suspend();

        #endregion

        #region music off
        //Boopseeker.Suspend();

        //Boopseeker2.Suspend();


        //Boopseeker3.Suspend();

        #endregion


        #region music on
        //Boopseeker.Resume();

        //Boopseeker2.Resume();


        //Boopseeker3.Resume();

        #endregion


        //Thread playtripleboopseek = new Thread(MusicFx.playstripleboopseek);
        // playtripleboopseek.Start();
        //Thread.Sleep(10);
        // playtripleboopseek.Suspend();


        //Thread selecttripleboopseek = new Thread(MusicFx.selecttripleboopseek);
        //playtripleboopseek.Start();

        // MusicFx.selecttripleboopseek(1);


        // maybe insane all over the screen slash glitch tech

        speakandspell = @" We met in Toyota’s labs in Massachusetts.
    There were several suited figures with compats.
    Compats are small devices that go near your temple and you send messages silently
        and non vocally.";


        Personality.OttoTypes(speakandspell);
        Thread.Sleep(magictime3000);
        CinemaHelpers.SpaceandClean();


        speakandspell = @"
     The future is insane it was once written and I believe that it is, yet in 
          many ways this is a beautiful insanity. Things are happening now that could have never
              happened before and time and action is compounding and compressing. ";
        Personality.OttoTypes(speakandspell);
        Thread.Sleep(magictime6000);
        CinemaHelpers.SpaceandClean();

        speakandspell = @" Where will the grind take us next?";
        Personality.OttoTypes(speakandspell);
        Thread.Sleep(magictime3000);
        CinemaHelpers.SpaceandClean();

        speakandspell = @"
    There was one fellow though with a black chrome notebook that had many implants obviously biology was not the end of this fellows evolution. 
    CD also had bioengineered hair. 
        His hair was modified to become soft quills that grew in a sublime arch jutting out past his chin and receding to the end of the back of his skull. ";

        Personality.Otto(speakandspell);


        //Personality.OttoTypes(speakandspell);
        Thread.Sleep(magictime9000);
        CinemaHelpers.SpaceandClean();
        //Personality.OttoTypes(speakandspell);
        //  Thread.Sleep(59000);
        //CinemaHelpers.SpaceandClean();



        // Good

        // playtripleboopseek.Suspend();
        //MusicFx.selecttripleboopseek(0);

        //maybe a red queen with initialize
        Personality.RedQueenNarrator("Initialize", 10);


        Thread.Sleep(30);
        CinemaHelpers.TheCorp();

        // Cd typing
        speakandspell = @" 

    ::: Cloak & Dagger :::


    Hey, gents nice to meet ye acquaintance, I am agent Cloak & Dagger, CD for short.";

        Soundz.Actor("cloakdaggerintro.wav");
        Console.WriteLine(speakandspell);
        Thread.Sleep(10000);
        CinemaHelpers.TheCorp();
        // playtripleboopseek.Resume();
        // Personality.CD(speakandspell);


        // maybe a quick squiggly line emf scan

        speakandspell = " We met in a meeting room that was scanned for listening devices by the spooks.";
        Personality.Otto(speakandspell);
        Thread.Sleep(magictime3000);
        CinemaHelpers.SpaceandClean();


        speakandspell = @"        
                   ~~  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~
                      ~ ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~ ~                              
                          ~~~~ ~~~~~~~~~~~ ~~~~~~~~~~~~~ ~~~~                          
                              ~ ~~~~~~~~~~ ~~~~~~~~~~ ~            
                                    ~ ~~~~ ~~~~ ~                                 
                                       ~~ ~ ~~                             
                                         ~ ~                           
                                          ~                          ";

        #region emfscan
        //emfscan
        for (int x = 0; x < 3; x++)
        {
            TextFx.grunblancheblack(speakandspell);
            if (x <= 3)
            {
                // MyTest.RedWhiteDance(speakandspell);
                TextFx.grunblancheblackdance(speakandspell);
                if (x <= 3)
                {
                    Thread.Sleep(30);
                    Console.Clear();
                }
            }
        }
        Personality.MegaByte("Scan Complete, no bugs Found");

        Thread.Sleep(98);
        CinemaHelpers.SpaceandClean();
        #endregion

        speakandspell = @" 


    CD opened up his laptop; he had a operating system that although it was made by a swede 
        sometime in the 90's. CD had thoroughly rewritten it there were no passwords on his 
            system his authentication method was biometric scans. ";


        Personality.Otto(speakandspell);
        Thread.Sleep(magictime9000);
        CinemaHelpers.SpaceandClean();

        speakandspell = @"


        At some point, he explained that things were too secure to actually be useable.
            He called this the unplugged disconnected machine of old. ";


        Personality.Otto(speakandspell);
        Thread.Sleep(magictime6000);
        CinemaHelpers.SpaceandClean();

        speakandspell = @"


                    Wireless Data and Energy Whirred about us.";


        Personality.OttoTypes(speakandspell);
        Thread.Sleep(magictime3000);
        CinemaHelpers.SpaceandClean();

        speakandspell = @"


            All machines were congolomeration of smaller virtual machines creating full hive computation all units acting as a superorganism.
";
        Personality.Otto(speakandspell);
        Thread.Sleep(magictime3000);
        CinemaHelpers.SpaceandClean();
        //Good

        speakandspell = @"

#! bin sh

prefix =  usr local
debugsym=true

for arg in $@/ do
    case $arg in
    --prefix = *)
        prefix =echo $arg | sed s/--";

        Happyboopulator.Resume();

        CinemaHelpers.commandconsole(speakandspell);
        // CinemaHelpers.CmdConType(speakandspell);
        // CinemaHelpers.CmdConWithTyping(speakandspell);

        speakandspell = @"
        --enable - debug)
        debugsym = true
        --disable - debug)
        debugsym = false

        --help)
";
        CinemaHelpers.commandconsole(speakandspell);
        //CinemaHelpers.CmdConWithTyping(speakandspell);

        speakandspell = @"
        echo usage: ./configure [options]
        echo options:
        echo   --prefix=<path>: installation prefix
        echo --enable-debug: include debug symbols
        echo   --disable-debug: do not include debug symbols
        echo all invalid options are silently ignored
        exit 0
        
        esac
    done ";

        CinemaHelpers.commandconsole(speakandspell);

        //CinemaHelpers.CmdConWithTyping(speakandspell);

        speakandspell = @"echo generating makefile ...
echo PREFIX = $prefix > Makefile
if $debugsym then
    echo dbg = -g >> Makefile
fi
cat Makefile.in >> Makefile
echo configuration complete, type make to build. ";

        // CinemaHelpers.CmdConWithTyping(speakandspell);
        CinemaHelpers.commandconsole(speakandspell);

        speakandspell = @" make ";
        CinemaHelpers.commandconsole(speakandspell);



        // CinemaHelpers.commandconsole(speakandspell);
        // playtripleboopseek.Resume();


        //MusicFx.selecttripleboopseek(1);



        Happyboopulator.Suspend();


        // MusicFx.selecttripleboopseek(0);
        // MusicFx.selecttripleboopseek.synth();
        // playtripleboopseek.Suspend();

        Thread.Sleep(60);

        speakandspell = @"


        Software imagined and encoded was interesting. Compats sent signals directly to
            interpretters so people could code at 500 words per minute and this was without ehancement. ";

        Personality.Otto(speakandspell);
        Thread.Sleep(magictime9000);
        CinemaHelpers.SpaceandClean();

        speakandspell = @"


        The populous was using software agents, as transferring
            redundant data was annoying. CD fired up some simulations that he and his colleagues had put together it
                the simulations were so good they seemed like hollywood blockbusters.  ";

        Personality.Otto(speakandspell);
        Thread.Sleep(magictime9000);
        CinemaHelpers.SpaceandClean();

        speakandspell = @"


                     In some corporations, they started paying idiots and geniuses alike too simply write ideas. 

                                                        The Idea Corp. ";


        Personality.Otto(speakandspell);
        Thread.Sleep(magictime6000);
        CinemaHelpers.SpaceandClean();
        //Good



        Graphix.GraphingCalculator();
        Thread.Sleep(1337);
        CinemaHelpers.TextSpace();

        speakandspell = @" 


                    In Idea Corp.  there were software and human analyzers that processed these ideas to find those that could be rapidly adapted. 
                        Then there were the reanalyzers reforumlated half cooked ideas or things that slipped by. ";

        Personality.Otto(speakandspell);
        Thread.Sleep(magictime9000);
        CinemaHelpers.SpaceandClean();



        speakandspell = @"

    Those organizations kept all of this information in giant data stores. 
        Every search page had better options for searching multiple check box methods that would quarantine searches to specific areas as to find 
                the information you were looking for. ";

        Personality.Otto(speakandspell);
        Thread.Sleep(magictime9000);
        CinemaHelpers.SpaceandClean();


        speakandspell = @"

    The information was so volumous that to do anything else would have difficult non trivial and unwise. Innovation and application was everywhere. 
        The presentation showed us strange transactions that seemed legitimate. ";



        Personality.Otto(speakandspell);
        Thread.Sleep(magictime9000);
        CinemaHelpers.SpaceandClean();

        speakandspell = @"  

        The money seemed to be non coherent and highly distributed. 
            Accounts were created for people. Credit was salami sliced, it was also stored in micro amounts in real accounts. 
                It was literally everywhere. 
 
 ";



        Personality.Otto(speakandspell);
        Thread.Sleep(magictime9000);
        CinemaHelpers.SpaceandClean();
        // close to good

        speakandspell = @"

su sudo create (n){
for x = 1 to n

@Override
public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        accessToken = AccessToken.getCurrentAccessToken();
    }

}
next n

";

        //for(int x = 0; x <2; x++)
        // {
        //CinemaHelpers.CmdConWithTyping(speakandspell);
        CinemaHelpers.commandconsole(speakandspell);
        // }


        speakandspell = @" 

    The creation of false identities was nothing new.  ";

        Personality.Otto(speakandspell);
        Thread.Sleep(magictime3000);
        CinemaHelpers.SpaceandClean();


        speakandspell = @"

    Techniques used by any one needing ways of laundering information and money. 
        If you have enough of them, they create a real burden in trying to keep track of where and how the money flows. ";

        Personality.Otto(speakandspell);
        Thread.Sleep(magictime9000);
        CinemaHelpers.SpaceandClean();

        speakandspell = @"

    Yet they seem to have some ideas about a hacking group that may have something to do with some of the transactions. 
        We have been tracking and watching this happen for sometime now, and now we have enough data to move forward.";

        Personality.Otto(speakandspell);
        Thread.Sleep(magictime9000);
        CinemaHelpers.SpaceandClean();


        speakandspell = @"

    CD discovered that you were working on some interesting developments he thought that some of them might have had play in what is happening with the data. ";

        Personality.Otto(speakandspell);
        Thread.Sleep(magictime6000);
        CinemaHelpers.SpaceandClean();
        // Close to Good

        Personality.RedQueenNarrator(" Fork ");

        Thread.Sleep(magictime6000);
        Console.Clear();

        speakandspell = @"

::: Cloak & Dagger :::


Professor 
        do 
          you 
             know 
                 of anyone working in 
                                    the lab that has access other than you to 
                                                                             the labs?

";
        //playtripleboopseek.Suspend();
        Soundz.Actor("cloakdaggerlabaccess.wav");
        Console.WriteLine(speakandspell);
        Thread.Sleep(magictime9000);
        CinemaHelpers.TheCorp();

        //playtripleboopseek.Resume();
        // Personality.CD(speakandspell);

        speakandspell = @"

        He pulled up a list of personnel that have access to the lab. 
            Do you know any thing that may have been going on these days?";

        Personality.Otto(speakandspell);
        Thread.Sleep(magictime9000);
        CinemaHelpers.SpaceandClean();
        // Tight

        Filez.ProfessorReads("ProgramLS.txt");
        //  Filez.readtxtbyline("ProgramLS.txt");

        Thread.Sleep(magictime9000);
        CinemaHelpers.SpaceandClean();


        // Show Report
        speakandspell = @"

    In our reports, no one in our labs was working at that time. So what do you think happened then? ";

        Personality.Miamoto(speakandspell);
        Thread.Sleep(magictime6000);
        CinemaHelpers.SpaceandClean();

        speakandspell = @"

            Mr. Heisenstein seems to have a hypothesis that there was a data injection to the net, and that general AI now lives there. ";

        Personality.Miamoto(speakandspell);
        Thread.Sleep(magictime6000);
        CinemaHelpers.SpaceandClean();

        speakandspell = @"

                                                We have reports and other data that backs up these claims. 
 ";

        Personality.Miamoto(speakandspell);
        Thread.Sleep(magictime6000);
        CinemaHelpers.SpaceandClean();
        // Good

        // maybe xcopy screen or other file copy for a few seconds.

        speakandspell = @"

        The agents took copies of the data that we had procured. 
            CD seemed excited by the thought that such a thing could have happened in his lifetime. ";

        Personality.Otto(speakandspell);
        Thread.Sleep(magictime9000);
        CinemaHelpers.SpaceandClean();

        speakandspell = @"

            CD was obviously no average g-man. After the Feds came back to me with little results 
                   although our friend CD really seems to believe the strange tale. ";

        Personality.Otto(speakandspell);
        Thread.Sleep(magictime9000);
        CinemaHelpers.SpaceandClean();

        speakandspell = @"

            His other cohorts could not fit the idea in their tiny little skulls. 
                The agents simply would not follow the logic.";

        Personality.Otto(speakandspell);
        Thread.Sleep(magictime9000);
        CinemaHelpers.SpaceandClean();

        speakandspell = @"

        The agents where typical humans that did not understand that we still do not know everything there is too know in the world. 
            This to me is no surprise since sometimes the best ideas need to be forced down the throats of others before they will even consider the possibility of the existence of a new idea. ";


        Personality.Otto(speakandspell);
        Thread.Sleep(magictime9000);
        CinemaHelpers.SpaceandClean();
        // Tight

        //playtripleboopseek.Suspend();

        CinemaHelpers.DejaVu();

        speakandspell = @"

        I had some theories for Nibble and Bytes destruction, yet as their progenitor, I would be unable to carry out such a function. ";


        Personality.Miamoto(speakandspell);
        Thread.Sleep(magictime6000);
        CinemaHelpers.SpaceandClean();

        speakandspell = @"

        I see them as life and I believe all life is sacred even if this is a new package of digital DNA. ";

        Personality.Miamoto(speakandspell);
        Thread.Sleep(magictime6000);
        CinemaHelpers.SpaceandClean();

        speakandspell = @"

        Who am I to in the end control the new combinatrics? ";

        Personality.Miamoto(speakandspell);
        Thread.Sleep(magictime6000);
        CinemaHelpers.SpaceandClean();

        speakandspell = @"

        I would rather see the randomness that created them continue to hone and sharpen them. 
            Although I created, the mutation engine in the end the software developed software and became aware.";

        Personality.Miamoto(speakandspell);
        Thread.Sleep(magictime9000);
        CinemaHelpers.SpaceandClean();

        speakandspell = @"

            It is a distilled essence of beauty. 
                I wish that there were more things that were as beautiful as the mathematical living constructs. 
 ";

        Personality.Miamoto(speakandspell);
        Thread.Sleep(magictime6000);
        CinemaHelpers.SpaceandClean();
        ////Tight

        Boopseeker.Suspend();

        speakandspell = @" Sometimes you just have to see the future work itself out. ";

        Personality.Miamoto(speakandspell);


        Thread.Sleep(magictime3000);
        CinemaHelpers.RefreshConsole();

        Happyboopulator.Resume();

        Thread NumRain  = new Thread(SpecialFx.numberrain);
        Thread NumRain2 = new Thread(SpecialFx.numberrain);
        Thread NumRain3 = new Thread(SpecialFx.numberrain);
        NumRain.Start();
        NumRain2.Start();
        NumRain3.Start();

        Screen.EndScreenWriter(speakandspell);

        CinemaHelpers.RefreshConsole();
        ////Tight

        #endregion

        #region EndScene


        // playtripleboopseek.Suspend();
        SpecialFx.Thinking();
        Happyboopulator.Suspend();


        // Comment Out Line Below For Full Movie
        Screen.Chapter10EndScreen();
        //Thread phonealwaysbusy = new Thread(Soundz.phonealwaysbusy);
        //phonealwaysbusy.Start();

        Soundz.PhoneBusy();


        speakandspell = @"
___________.__                               ___________           .___
\__    ___/|  |__   ____                     \_   _____/ ____    __| _/
  |    |   |  |  \_/ __ \                     |    __)_ /    \  / __ | 
  |    |   |   Y  \  ___/                     |        \   |  \/ /_/ | 
  |____|   |___|  /\___  >                   /_______  /___|  /\____ | 
                \/     \/                            \/     \/      \/ ";
        //SweetNess

        //  MyTest.RainbowWriterFG(speakandspell);
        CinemaHelpers.SpaceandClean();
        Console.WriteLine(speakandspell);
        Thread.Sleep(80);
        CinemaHelpers.SpaceandClean();
        //SpecialFx.RainbowWriterBG(speakandspell);
        Screen.EndScreenWriter(speakandspell);
        //phonealwaysbusy.Suspend();


        CinemaHelpers.SpaceandClean();



        speakandspell = @"The program '[11128] - IntraLocution' has exited with code -1073741510 (0xc000013a)";
        Console.WriteLine(speakandspell);
        Console.ReadKey();

        Environment.Exit(0);

        #endregion
    }
Ejemplo n.º 34
0
        public static void pauseTimer()
        {
            Console.WriteLine("What thread would you like to pause/resume?");
            userInput = Console.ReadLine();
            int.TryParse(userInput, out iuserInput);

            switch (iuserInput)
            {
            case 1:
                if (thread1.IsAlive && thread1.ThreadState != ThreadState.Suspended)
                {
                    thread1.Suspend();
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("\nTHREAD 1 and the timer associated with it has been paused.\n");
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
                else if (thread1.IsAlive)
                {
                    thread1.Resume();
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("\nTHREAD 1 and the timer associated with it has been resumed.\n");
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
                break;

            case 2:
                if (thread2.IsAlive && thread2.ThreadState != ThreadState.Suspended)
                {
                    thread2.Suspend();
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("\nTHREAD 2 and the timer associated with it has been paused.\n");
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
                else if (thread2.IsAlive)
                {
                    thread1.Resume();
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("\nTHREAD 2 and the timer associated with it has been resumed.\n");
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
                break;

            case 3:
                if (thread3.IsAlive && thread3.ThreadState != ThreadState.Suspended)
                {
                    thread3.Suspend();
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("\nTHREAD 3 and the timer associated with it has been paused.\n");
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
                else if (thread3.IsAlive)
                {
                    thread1.Resume();
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("\nTHREAD 3 and the timer associated with it has been resumed.\n");
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
                break;

            case 4:
                if (thread4.IsAlive && thread4.ThreadState != ThreadState.Suspended)
                {
                    thread4.Suspend();
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("\nTHREAD 4 and the timer associated with it has been paused.\n");
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
                else if (thread4.IsAlive)
                {
                    thread1.Resume();
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("\nTHREAD 4 and the timer associated with it has been resumed.\n");
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
                break;

            default:
                Console.BackgroundColor = ConsoleColor.Red;
                Console.ForegroundColor = ConsoleColor.Black;
                Console.WriteLine("\nThat thread does not exist.\n");
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.BackgroundColor = ConsoleColor.Black;
                break;
            }
        }
 public static void ReceiveThreadStart()
 {
     Status="Start listening";
     if ( client!= null)  client.Close();
         receiveThread = new Thread(new ThreadStart(ReceiveString));
         receiveThread.IsBackground = true;
         if(receiveThread.IsAlive)receiveThread.Resume();
         else receiveThread.Start();
 }