void ProgressPanelUpdate(int p, string status = "", List <CTaskInfo> SessionInfo = null) { if (SessionInfo == null) { SessionInfo = new List <CTaskInfo> { }; } if (status.Length > 0) { SessionInfo.Add(new CTaskInfo { Details = status }); } Pages[Navigation.ActivePage].OnLoadAsync.ReportProgress(p, SessionInfo); }
public void Message_Received(object sender, MessageReceivedEventArgs args) { var originObj = args.MessageObj; Identity id; switch (originObj) { case PrivateMsg privateMsg: id = new Identity(privateMsg.UserId, MessageType.Private); break; case DiscussMsg discussMsg: id = new Identity(discussMsg.DiscussId, MessageType.Discuss); break; case GroupMsg groupMsg: id = new Identity(groupMsg.GroupId, MessageType.Group); break; default: throw new ArgumentException(); } SessionInfo.Add(originObj); if (SessionInfo[id].MsgQueue.Count < SessionInfo[id].MsgLimit) // 允许缓存n条,再多的丢弃 { SessionInfo[id].MsgQueue.Enqueue(originObj); } else if (!SessionInfo[id].LockMsg) { SessionInfo[id].LockMsg = true; SendMessage(new CommonMessageResponse(originObj.Message, new CommonMessage(originObj))); } if (!SessionInfo[id].TryRun(() => DispatchMessage(originObj))) { Info("当前已有" + SessionInfo[id].MsgQueue.Count + "条消息在" + SessionInfo[id].Name + "排队"); } }