static void Thread_Terminator(Object param, bool timedOut) { CThreadPoolData args = (CThreadPoolData)param; if (args.GetActivation() == true) { Console.WriteLine("Finished " + args.nIndex.ToString("N0")); } else if (args.GetActivation() == false) { //MessageBox.Show("Jobs are Canceled.", "INFO", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void tLifeCyle_Tick(object sender, EventArgs e) { try { PATH_BASE_LOG_FILE = CSupport.GetBaseLogFileName().Replace(".LOG", "_LIFE.LOG"); string PathLogFile = CSupport.GetFullLogFileName(PATH_BASE_FOLDER, PATH_BASE_LOG_FILE); CThreadPoolData thrFather = new CThreadPoolData(PathLogFile, CSupport.TIME_GetTimeCode_MD_HMS_MS() + " : I'am Alive.\r\n", m_workIndexer++); ThreadPool.QueueUserWorkItem(new WaitCallback(Thread_Worker), thrFather); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
//***************************************************************************************** static void Thread_Worker(Object param) { CThreadPoolData args = (CThreadPoolData)param; if (args.GetActivation() == true) { try { if (File.Exists(args.basePath) == false) { StreamWriter sw = File.CreateText(args.basePath); { string strTimeCode = CSupport.TIME_GetTimeCode_MD_HMS_MS(); string Tag = "[FILE CREATION]"; string msg = "Newly File has generated."; sw.WriteLine(strTimeCode + " : " + Tag + " " + msg + System.Environment.NewLine); } sw.Close(); } else { //StreamWriter sw = File.AppendText(args.basePath); using (StreamWriter sw = new StreamWriter(args.basePath, true)) { sw.WriteLine(args.msg); } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); Console.WriteLine(args.msg); } } if (args.GetActivation() == false) { AutoResetCom.Set(); } }
//***************************************************************************************** public void WRITE_LOG(string msg, string Tag) { string strTimeCode = CSupport.TIME_GetTimeCode_MD_HMS_MS(); string temp = strTimeCode + " : " + Tag + " " + msg + System.Environment.NewLine; string HeaderCut = temp; m_msg.Append(temp); this.UIThread(delegate { if (CHK_00_ALL.Checked == true) { HeaderCut = _RemoveHeaders(temp); RICH_MESSAGE.AppendText(HeaderCut); RICH_MESSAGE.ScrollToCaret(); } else if (CHK_00_ALL.Checked == false) { System.Threading.Thread thr = new Thread(delegate() { UpdatePrintContents(m_msg, RICH_MESSAGE, m_listCheckBox); }); thr.IsBackground = true; thr.Start(); } }); if (poolManager.GetActivation() == false) { poolManager.SetActivation(true); } PATH_BASE_LOG_FILE = CSupport.GetBaseLogFileName(); string PathLogFile = CSupport.GetFullLogFileName(PATH_BASE_FOLDER, PATH_BASE_LOG_FILE); CThreadPoolData thrFather = new CThreadPoolData(PathLogFile, temp, m_workIndexer++); ThreadPool.QueueUserWorkItem(new WaitCallback(Thread_Worker), thrFather); }