using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.UserCenter { /// /// 线程逻辑(创建这个东西,是为了Log出力) /// public class HdlThreadLogic { #region ■ 变量声明___________________________ /// /// 线程逻辑(创建这个东西,是为了Log出力) /// private static HdlThreadLogic m_Current = null; /// /// 线程逻辑(创建这个东西,是为了Log出力) /// public static HdlThreadLogic Current { get { if (m_Current == null) { m_Current = new HdlThreadLogic(); } return m_Current; } } #endregion #region ■ 线程执行___________________________ /// /// 子线程执行(创建这个东西,是为了Log出力) /// public void RunThread(Action action) { new System.Threading.Thread(() => { //记录起当前界面,虽然似乎没啥用 string nowFormId = UserCenterResourse.NowActionFormID; try { action.Invoke(); action = null; } catch (Exception ex) { Application.RunOnMainThread(() => { //出现未知错误,数据丢失 var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnknownErrorAndDataLost)); alert.Show(); }); //Log出力 string msg = "当前激活的界面[" + nowFormId + "]\r\n"; msg += ex.Message + "\r\n"; msg += ex.TargetSite.ToString(); HdlLogLogic.Current.WriteLog(-1, msg); } }) { IsBackground = true }.Start(); } /// /// 执行运行子线程里面的主线程(创建这个东西,是为了Log出力) /// public void RunMainInThread(Action action) { new System.Threading.Thread(() => { Application.RunOnMainThread(() => { //记录起当前界面,虽然似乎没啥用 string nowFormId = UserCenterResourse.NowActionFormID; try { action.Invoke(); action = null; } catch (Exception ex) { //出现未知错误,数据丢失 var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnknownErrorAndDataLost)); alert.Show(); //Log出力 string msg = "当前激活的界面[" + nowFormId + "]\r\n"; msg += ex.Message + "\r\n"; msg += ex.TargetSite.ToString(); HdlLogLogic.Current.WriteLog(-1, msg); } }); }) { IsBackground = true }.Start(); } #endregion } }