static void Prog6() { TickTock tt = new TickTock(); MyThread2 mt1 = new MyThread2("Tick", tt); MyThread2 mt2 = new MyThread2("Tock", tt); mt1.thrd.Join(); mt2.thrd.Join(); Console.WriteLine("Часы остановлены"); }
// // // protected void DoAck(TreeLbItem ti) { if (MessageBoxResult.OK != MessageBox.Show("Do you really want to acknowledge message?\n\n(press Back to Cancel)")) { return; } if (m_sUserIDlast.Length == 0) { return; } string sPath = AppLogic.csSecretsFolder + "\\" + m_sUserIDlast; RscStore store = new RscStore(); sPath += "\\Threads"; if (!store.FolderExists(sPath)) { return; } MyThread2 th = new MyThread2(); th = store.ReadXmlDataFile(sPath + "\\" + ti.sID + "\\" + ti.sHistoryID + ".xml", th); if (th.ID.Length == 0) { return; //FAIL!!! } th.DateAcked = DateTime.Now; store.WriteXmlDataFile(sPath + "\\" + ti.sID + "\\" + ti.sHistoryID + ".xml", th, true); ti.BtnCustom1Visibility = Rsc.Collapsed; ti.DetailsOfTitle = TreeLbItemThread.DecorateSnippet(th); ti.ClearCustomBackColor(); int iCount_NonAckAll = 0; iCount_NonAckAll = store.ReadXmlDataFile(sPath + "\\" + "Count_NonAck" + ".xml", iCount_NonAckAll); iCount_NonAckAll = Math.Max(0, iCount_NonAckAll - 1); store.WriteXmlDataFile(sPath + "\\" + "Count_NonAck" + ".xml", iCount_NonAckAll, true); int iCountAll = 0; iCountAll = store.ReadXmlDataFile(sPath + "\\" + "Count" + ".xml", iCountAll); UpdateSumItem(iCount_NonAckAll, iCountAll); m_AppFrame.StatusText = ""; //To refresh mem info... }
public static string DecorateSnippet(MyThread2 th) { string sRet = RscJSon.UnDecorate(th.Snippet); //Making more readable... sRet += "..."; sRet = sRet.Replace("! ", "!\n\n"); sRet = sRet.Replace(". ", ".\n\n"); //Adding HisID to debug, test, etc... sRet += "\n\n(History ID: " + th.HistoryID + ")"; if (th.Acknowledged) { sRet += "\n(acknowledged: " + th.DateAcked.ToString() + ")"; } return(sRet); }
private void ShowSavedThreadData(string sPath, int iStartIndex, TreeLbItem tiHead = null) { RscStore store = new RscStore(); sPath += "\\Threads"; if (!store.FolderExists(sPath)) { return; } int iCountAll = 0; iCountAll = store.ReadXmlDataFile(sPath + "\\" + "Count" + ".xml", iCountAll); int iCount_NonAckAll = 0; iCount_NonAckAll = store.ReadXmlDataFile(sPath + "\\" + "Count_NonAck" + ".xml", iCount_NonAckAll); if (iStartIndex == 0) { m_tiSum = new TreeLbItem(m_aTI, null); m_tiSum.DetailsFontSize = cdFontSize; UpdateSumItem(iCount_NonAckAll, iCountAll); m_aTI.Add(m_tiSum); tiHead = new TreeLbItem(m_aTI, null); //tiHead.DetailsFontSize = cdFontSize; tiHead.DetailsOnly = "..."; m_aTI.Add(tiHead); } string sThreadIdOrder = ""; sThreadIdOrder = store.ReadTextFile(sPath + "\\" + "IdOrder" + ".txt", sThreadIdOrder); string [] asThreadIdOrders = sThreadIdOrder.Split('|'); bool bMoreItems = false; int iThCnt = asThreadIdOrders.Length; for (int iTh = iStartIndex; iTh < iThCnt; iTh++) { //NOT all... if ((iTh - iStartIndex) >= ciMaxAtOnce) { bMoreItems = true; break; } string sID = asThreadIdOrders[iTh]; if (sID.Length == 0) { continue; } if (!store.FolderExists(sPath + "\\" + sID)) { continue; } string sIdOrder = ""; sIdOrder = store.ReadTextFile(sPath + "\\" + sID + "\\" + "IdOrder" + ".txt", sIdOrder); string [] asIdOrders = sIdOrder.Split('|'); string sHistoryID = asIdOrders[0]; if (sHistoryID.Length == 0) { continue; } if (!store.FileExists(sPath + "\\" + sID + "\\" + sHistoryID + ".xml")) { continue; } MyThread2 th = new MyThread2(); th = store.ReadXmlDataFile(sPath + "\\" + sID + "\\" + sHistoryID + ".xml", th); if (th.ID.Length == 0) { continue; } TreeLbItem ti = new TreeLbItem(m_aTI, null); // ti.DetailsFontSize = cdFontSize; ti.DetailsBackColor = m_AppFrame.Theme.ThemeColors.TextDarkBack; ti.DetailsForeColor = m_AppFrame.Theme.ThemeColors.TextDarkFore; if (!th.Acknowledged) { ti.CustomBackColor = Colors.Orange; ti.BtnCustom1Visibility = Rsc.Visible; } ti.BtnCustom1Image = m_isCheckOn; //Off; // string sTitle = ""; sTitle += RscUtils.toDateDiff(th.DateSaved); if (asIdOrders.Length > 1) { sTitle += " ( +" + (asIdOrders.Length - 1).ToString() + " )"; } ti.Title = sTitle; ti.DetailsOfTitle = TreeLbItemThread.DecorateSnippet(th); ti.IsLeaf = (asIdOrders.Length <= 1); m_aTI.Add(ti); ti.sID = sID; ti.sHistoryID = sHistoryID; foreach (string sId in asIdOrders) { if (sId.Length == 0) { continue; } if (sId == sHistoryID) { continue; } MyThread2 thSub = new MyThread2(); thSub = store.ReadXmlDataFile(sPath + "\\" + sID + "\\" + sId + ".xml", thSub); if (thSub.ID.Length == 0) { continue; } //DO NOT!!! /* * TreeLbItem tiSub = new TreeLbItem( m_aTI, ti ); * tiSub.Title = RscUtils.toDateDiff( thSub.DateSaved ) + "retrived..."; * tiSub.DetailsOfTitle = thSub.Snippet; * tiSub.IsLeaf = true; * m_aTI.Add( tiSub ); */ ti.m_a.Add(thSub); } } if (tiHead != null) { string sTit = "Threads " + (iStartIndex + 1).ToString() + " - "; if (bMoreItems) { sTit += (iStartIndex + ciMaxAtOnce).ToString(); } else { sTit += iThCnt.ToString(); } //tiHead.DetailsFontSize = cdFontSize; tiHead.DetailsOnly = sTit; } if (bMoreItems) { TreeLbItem ti = new TreeLbItem(m_aTI, null); ti.Title = "Threads " + (iStartIndex + ciMaxAtOnce + 1).ToString() + " - ... (press to list)"; ti.sID = csMoreItems; ti.sHistoryID = (iStartIndex + ciMaxAtOnce).ToString(); ti.CustomBackColor = m_AppFrame.Theme.ThemeColors.TreeDescBack; ti.CustomForeColor = m_AppFrame.Theme.ThemeColors.TreeDescFore; m_aTI.Add(ti); } }