private void Run() { try { TimeSpan timeout = TimeSpan.FromSeconds(1.0); bufferReadyEvent.Set(); while (!token.IsCancellationRequested) { if (!dataReadyEvent.WaitOne(timeout)) { continue; } if (OCR.Warframe != null) { using (MemoryMappedViewStream stream = memoryMappedFile.CreateViewStream()) { using (BinaryReader reader = new BinaryReader(stream, Encoding.Default)) { uint processId = reader.ReadUInt32(); if (processId == OCR.Warframe.Id) { char[] chars = reader.ReadChars(4092); int index = Array.IndexOf(chars, '\0'); string message = new string(chars, 0, index); TextChanged(this, message.Trim()); } } } } bufferReadyEvent.Set(); } } catch (Exception ex) { Main.AddLog(ex.ToString()); Main.RunOnUIThread(() => { _ = new ErrorDialogue(DateTime.Now, 0); }); } finally { if (memoryMappedFile != null) { memoryMappedFile.Dispose(); } if (bufferReadyEvent != null) { bufferReadyEvent.Dispose(); } if (dataReadyEvent != null) { dataReadyEvent.Dispose(); } } }
public static void ThreadedDataLoad() { try { StatusUpdate("Updating Databases...", 0); dataBase.Update(); //RelicsWindow.LoadNodesOnThread(); OCR.Init(); if ((bool)Settings.settingsObj["Auto"]) { dataBase.EnableLogCapture(); } if (dataBase.IsJWTvalid().Result) { OCR.VerifyWarframe(); latestActive = DateTime.UtcNow.AddMinutes(1); LoggedIn(); var startTimeSpan = TimeSpan.Zero; var periodTimeSpan = TimeSpan.FromMinutes(1); timer = new System.Threading.Timer((e) => { TimeoutCheck(); }, null, startTimeSpan, periodTimeSpan); } StatusUpdate("WFInfo Initialization Complete", 0); AddLog("WFInfo has launched successfully"); FinishedLoading(); } catch (Exception ex) { AddLog("LOADING FAILED"); AddLog(ex.ToString()); StatusUpdate("Launch Failure - Please Restart", 0); RunOnUIThread(() => { _ = new ErrorDialogue(DateTime.Now, 0); }); } }
// timestamp is the time to look for, and gap is the threshold of seconds different public static void SpawnErrorPopup(DateTime timeStamp, int gap = 30) { popup = new ErrorDialogue(timeStamp, gap); }