/// <summary> /// 中断任务重连线程 /// </summary> private void ApplicationResetThread() { while (this._launch) { for (int i = 0; i < _suspendTaskContexts.Count; i++) { SuspendTaskContext task = _suspendTaskContexts[i]; string id = task.AdapterHandler.IdentifyId.Split('|')[0]; var syncContext = SessionSyncContexts.FirstOrDefault(x => x.KeyDictions[SysConstants.IdentifyId].ConvertTo <string>() == id); LogHelper.WriteErrorByCurrentMethod("beigin Reset--{0},{1},{2}".FormatTo(task.AdapterHandler.ApplicationKey, task.AdapterHandler.IdentifyId, id)); if (!syncContext.IsNull()) { if (task.AdapterHandler.WhetherClose) { //窗口关闭将不再建立连接 _suspendTaskContexts.Remove(task); i--; continue; } HasComWithSendTo(syncContext.Session, MessageHead.S_MAIN_ACTIVATE_APPLICATIONSERVICE, new ActivateServicePack() { ApplicationKey = task.AdapterHandler.ApplicationKey }); LogHelper.WriteErrorByCurrentMethod("send reset command--{0},{1},{2}".FormatTo(task.AdapterHandler.ApplicationKey, task.AdapterHandler.IdentifyId, id)); } } Thread.Sleep(5000); } }
/// <summary> /// 加入重连线程 /// </summary> /// <param name="context"></param> public void AddSuspendTaskContext(SuspendTaskContext context) { _suspendTaskContexts.Add(context); LogHelper.WriteErrorByCurrentMethod("Session Close--{0},{1}".FormatTo(context.AdapterHandler.ApplicationKey, context.AdapterHandler.IdentifyId)); }