//tests a multi-threaded workers public void test6() { DateTime startTime = DateTime.Now; initQueuesTest3(); RuntimeStatistics.addToExtractedUrls(1); RuntimeStatistics.addToFeedUrls(5000); RankFrointer rankFrontier = new RankFrointer(feedback, serverQueues); Thread frontierThread = new Thread(new ThreadStart(rankFrontier.sceduleTasks)); frontierThread.Start(); Thread workerThread = new Thread(new ThreadStart(workerSimulator4)); workerThread.Start(); Thread workerThread2 = new Thread(new ThreadStart(workerSimulator5)); workerThread2.Start(); int iteration = 5000; while (true) { Thread.Sleep(10); fillQueue(iteration, iteration + 5000); iteration += 5000; RuntimeStatistics.addToFeedUrls(5000); StatusDisplay.DisplayOnScreen(feedback, serverQueues); if (iteration > 1000000) { break; } } while (true) { Thread.Sleep(1000); StatusDisplay.DisplayOnScreen(feedback, serverQueues); //workerThread.Interrupt(); ThreadState state = workerThread.ThreadState; Console.WriteLine("Workerthread is : " + state.ToString()); ThreadState state2 = workerThread2.ThreadState; if ((state == ThreadState.Stopped) && (state2 == ThreadState.Stopped)) { //continue; //workerThread2.Join(); DateTime endTime = DateTime.Now; TimeSpan totalTime = endTime - startTime; } Console.WriteLine("Workerthread2 is : " + state2.ToString()); } }
public static void getThreads() { Process thisProc = Process.GetCurrentProcess(); ProcessThreadCollection myThreads = thisProc.Threads; foreach (ProcessThread pt in myThreads) { DateTime startTime = pt.StartTime; TimeSpan cpuTime = pt.TotalProcessorTime; int priority = pt.BasePriority; ThreadState ts = pt.ThreadState; Console.WriteLine("thread: {0}", pt.Id); Console.WriteLine(" started: {0}", startTime.ToString()); Console.WriteLine(" CPU time: {0}", cpuTime); Console.WriteLine(" priority: {0}", priority); Console.WriteLine(" thread state: {0}", ts.ToString()); } }
public static void getListofThreads() { Process[] allProcs = Process.GetProcesses(); foreach (Process proc in allProcs) { ProcessThreadCollection myThreads = proc.Threads; Console.WriteLine("process: {0}, id: {1}", proc.ProcessName, proc.Id); foreach (ProcessThread pt in myThreads) { //DateTime startTime = pt.StartTime; //TimeSpan cpuTime = pt.TotalProcessorTime; int priority = pt.BasePriority; ThreadState ts = pt.ThreadState; Console.WriteLine(" thread: {0}", pt.Id); //Console.WriteLine(" started: {0}", startTime.ToString()); //Console.WriteLine(" CPU time: {0}", cpuTime); Console.WriteLine(" priority: {0}", priority); Console.WriteLine(" thread state: {0}", ts.ToString()); } } }
private void toolStripButton2_Click(object sender, EventArgs e) { if (t != null) { ThreadState s = new ThreadState(); s = t.ThreadState; if (s.ToString() == "Running") t.Suspend(); else if (s.ToString() == "Suspended") t.Resume(); } }
public override void OnMessage(string message, EChatEntryType type) { if (message == "LIST" && Bot.MySteamID.Contains(OtherSID.ToString())) { List <long> contextId = new List <long>(); contextId.Add(2); Bot.mySteamInventory.load(Bot.BotGameUsage, contextId, Bot.SteamClient.SteamID); SendChatMessage("My inventory (" + Bot.BotGameUsage + ") contain " + Bot.mySteamInventory.items.Count + " item(s) !"); foreach (KeyValuePair <ulong, GenericInventory.Item> item in Bot.mySteamInventory.items) { SteamTrade.GenericInventory.ItemDescription description = Bot.mySteamInventory.getDescription(item.Key); SendChatMessage(description.name + " in game " + Bot.mySteamInventory.items[item.Key].appid); } } else if (message == "TCP" && Bot.MySteamID.Contains(OtherSID.ToString())) { ThreadState state = Bot.StartListening.ThreadState; SendChatMessage(state.ToString()); } else if (message.StartsWith("EXEC") && Bot.MySteamID.Contains(OtherSID.ToString())) { message = message.Replace("EXEC", ""); string[] cmd = message.Split(' '); if (cmd.Length >= 2) { string command = ""; for (int i = 2; i < cmd.Length; i++) { command += cmd[i] + " "; } command.Remove(command.Length - 1); if (Bot.SendCommandToServer(Int32.Parse(cmd[1]), command)) { SendChatMessage("Executed '" + command + "' on server id '" + cmd[1] + "' !"); } else { SendChatMessage("Wrong server ID, use 'SERVERLIST' to get the server ID."); } } else { SendChatMessage("Usage : EXEC [serverid] [command]"); SendChatMessage("Exemple : EXEC 0 sm_test 1 2 3"); } } else if (message == "SERVERLIST" && Bot.MySteamID.Contains(OtherSID.ToString())) { List <string> existingServer = new List <string>(); SendChatMessage("Number of connection : " + Bot.socket.Clients.Count); SendChatMessage("Server ID Server name"); for (int i = 0; i < Bot.socket.Clients.Count; i++) { if (!existingServer.Contains(Bot.socket.Clients[i].Name) && Bot.socket.Clients[i].clientSocket.Connected) { SendChatMessage(i + " " + Bot.socket.Clients[i].Name); existingServer.Add(Bot.socket.Clients[i].Name); } } SendChatMessage("-----------------------"); } else { SendChatMessage(Bot.chatbotSession.Think(message)); } }