public void deviceInfoThread(iosSyslogger form, loggerTool tool, string uuid) //Create thread for Device info reader { Thread deviceInfoThread = new Thread(() => tool.readDeviceinfo(form, uuid)); deviceInfoThread.IsBackground = true; lstThreads.Add(deviceInfoThread); }
public void readDeviceUUID(iosSyslogger form, loggerTool tool) { string currentPath = System.Environment.CurrentDirectory; Process process = new Process(); process.StartInfo.FileName = currentPath + @"\deviceid.exe"; process.StartInfo.Arguments = "-l"; process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.OutputDataReceived += new DataReceivedEventHandler((source, e) => uuidinfoHandler(source, e, form)); //* Start process and handlers process.Start(); process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); if (Program.GlobalData.usbRemoved == true) //Called after usb waas removed { foreach (string uuidt in Program.GlobalData.uuid) { Process test = new Process(); if (!(crProcess.TryGetValue(uuidt, out test))) { continue; } if (!Program.GlobalData.tempuuid.Contains(uuidt) && uuidt != null && crProcess[uuidt] != null) { crProcess[uuidt].Kill(); crProcess.Remove(uuidt); } } Program.GlobalData.uuid.Clear(); Program.GlobalData.uuid.AddRange(Program.GlobalData.tempuuid); foreach (string uuidstring in Program.GlobalData.uuid) { Thread loggingThread = new Thread(() => tool.readDeviceinfo(form, uuidstring)); loggingThread.IsBackground = true; loggingThread.Start(); } Program.GlobalData.usbRemoved = false; return; } else if (Program.GlobalData.usbInserted == true) //Called after usb was inserted { if (Program.GlobalData.uuid[Program.GlobalData.uuid.Count - 1] == null) { return; } else { deviceInfoThread(form, tool, Program.GlobalData.uuid[Program.GlobalData.uuid.Count - 1]); LoggingThread(form, tool, Program.GlobalData.uuid[Program.GlobalData.uuid.Count - 1]); lstThreads[lstThreads.Count - 2].Start(); lstThreads[lstThreads.Count - 1].Start(); Program.GlobalData.notInit = true; return; } } else if (Program.GlobalData.usbInserted != true) //First time initiated { if (Program.GlobalData.usbInserted == true) { return; } foreach (string uuid in Program.GlobalData.uuid) { deviceInfoThread(form, tool, uuid); LoggingThread(form, tool, uuid); } foreach (Thread th in lstThreads) { th.Start(); } return; } else { return; } }
public void readDeviceUUID(iosSyslogger form, loggerTool tool) { string currentPath = System.Environment.CurrentDirectory; Process process = new Process(); process.StartInfo.FileName = currentPath + @"\deviceid.exe"; process.StartInfo.Arguments = "-l"; process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.OutputDataReceived += new DataReceivedEventHandler((source, e) => uuidinfoHandler(source, e, form)); //* Start process and handlers process.Start(); process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); if (Program.GlobalData.usbRemoved == true) //Called after usb waas removed { foreach (string uuidt in Program.GlobalData.uuid) { Process test = new Process(); if (!(crProcess.TryGetValue(uuidt, out test))) { continue; } if (!Program.GlobalData.tempuuid.Contains(uuidt) && uuidt != null && crProcess[uuidt] != null) { crProcess[uuidt].Kill(); crProcess.Remove(uuidt); } } Program.GlobalData.uuid.Clear(); Program.GlobalData.uuid.AddRange(Program.GlobalData.tempuuid); foreach (string uuidstring in Program.GlobalData.uuid) { Thread loggingThread = new Thread(() => tool.readDeviceinfo(form, uuidstring)); loggingThread.IsBackground = true; loggingThread.Start(); } Program.GlobalData.usbRemoved = false; return; } else if (Program.GlobalData.usbInserted == true) //Called after usb was inserted { if (Program.GlobalData.uuid[Program.GlobalData.uuid.Count - 1] == null) return; else { deviceInfoThread(form, tool, Program.GlobalData.uuid[Program.GlobalData.uuid.Count - 1]); LoggingThread(form, tool, Program.GlobalData.uuid[Program.GlobalData.uuid.Count - 1]); lstThreads[lstThreads.Count - 2].Start(); lstThreads[lstThreads.Count - 1].Start(); Program.GlobalData.notInit = true; return; } } else if (Program.GlobalData.usbInserted!=true) //First time initiated { if (Program.GlobalData.usbInserted == true) return; foreach (string uuid in Program.GlobalData.uuid) { deviceInfoThread(form, tool, uuid); LoggingThread(form, tool, uuid); } foreach (Thread th in lstThreads) { th.Start(); } return; } else return; }
//Create thread for Device info reader public void deviceInfoThread(iosSyslogger form, loggerTool tool, string uuid) { Thread deviceInfoThread = new Thread(() => tool.readDeviceinfo(form,uuid)); deviceInfoThread.IsBackground = true; lstThreads.Add(deviceInfoThread); }