private ChatlogResult GetChatlog(int timeout = 5000) { var cts = new CancellationTokenSource(timeout); var clr = new ChatlogResult(null, -1); var task = Task.Run <ChatlogResult>(() => { var buffer = new List <ChatlogLine>(); var holder = new ChatlogResult(null, -1); try { holder = rd.GetChatLog(); buffer.AddRange(holder.LogLines); while (holder.Remaining > 0) { cts.Token.ThrowIfCancellationRequested(); holder = rd.GetChatLog(holder.Remaining); buffer.AddRange(holder.LogLines); } return(new ChatlogResult(buffer, holder.Remaining)); } catch { return(new ChatlogResult(buffer, holder.Remaining)); } }, cts.Token); task.Wait(cts.Token); return(task.Result ?? clr); }
private static void PackLogData(ChatlogResult result) { if (!_scanned) { RunMemoryTask(); _scanned = true; } IpcClient.SendData(new PackedResult(PackedResultType.Chatlog, result)); }