private void RefreshHistoryWorkerCompleted(HistoryList hist) { if (!PendingClose) { if (hist != null) { history.Copy(hist); OnRefreshCommanders?.Invoke(); if (history.CommanderId >= 0 && history.CommanderId != EdsmLogFetcher.CommanderId) // not hidden, and not last cmdr { EdsmLogFetcher.StopCheck(); // ENSURE stopped. it was asked to be stop on the refresh, so should be EdsmLogFetcher = new EDSMLogFetcher(history.CommanderId, LogLine); EdsmLogFetcher.OnDownloadedSystems += () => RefreshHistoryAsync(); } ReportProgress(-1, ""); LogLine("Refresh Complete."); RefreshDisplays(); } HistoryRefreshed?.Invoke(this, EventArgs.Empty); // Internal hook call journalmonitor.StartMonitor(); EdsmLogFetcher.Start(); // EDSM log fetcher was stopped, restart it.. ignored if not a valid commander or disabled. OnRefreshComplete?.Invoke(); // History is completed refreshRequestedFlag = 0; readyForNewRefresh.Set(); } }
// Called on foreground after history has refreshed private void ForegroundHistoryRefreshCompleteonUI(HistoryList hist) { Debug.Assert(System.Windows.Forms.Application.MessageLoop); if (!PendingClose) { Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Refresh history worker completed"); if (hist != null) { history.Copy(hist); OnRefreshCommanders?.Invoke(); EdsmLogFetcher.StopCheck(); Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Refresh Displays"); OnHistoryChange?.Invoke(history); Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Refresh Displays Completed"); } Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " JM On"); journalmonitor.StartMonitor(); Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Call Refresh Complete"); OnRefreshComplete?.Invoke(); // History is completed if (history.CommanderId >= 0) { EdsmLogFetcher.Start(EDCommander.Current); } refreshHistoryRequestedFlag = 0; readyForNewRefresh.Set(); // say i'm okay for another refresh System.Diagnostics.Debug.WriteLine("Refresh completed, allow another refresh"); LogLine("History refresh complete.".T(EDTx.EDDiscoveryController_HRC)); ReportRefreshProgress(-1, ""); Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Refresh history complete"); } }
private void RefreshHistoryWorkerCompleted(HistoryList hist) { if (!PendingClose) { Debug.WriteLine(BaseUtils.AppTicks.TickCount100 + " Refresh history worker completed"); if (hist != null) { history.Copy(hist); OnRefreshCommanders?.Invoke(); EdsmLogFetcher.StopCheck(); ReportProgress(-1, ""); LogLine("Refresh Complete."); RefreshDisplays(); Debug.WriteLine(BaseUtils.AppTicks.TickCount100 + " Refresh Displays Completed"); } Debug.WriteLine(BaseUtils.AppTicks.TickCount100 + " HR Refresh"); HistoryRefreshed?.Invoke(this, EventArgs.Empty); // Internal hook call Debug.WriteLine(BaseUtils.AppTicks.TickCount100 + " JMOn"); journalmonitor.StartMonitor(); Debug.WriteLine(BaseUtils.AppTicks.TickCount100 + " RFcomplete"); OnRefreshComplete?.Invoke(); // History is completed if (history.CommanderId >= 0) { EdsmLogFetcher.Start(EDCommander.Current); } refreshRequestedFlag = 0; readyForNewRefresh.Set(); Debug.WriteLine(BaseUtils.AppTicks.TickCount100 + " refresh history complete"); } }
private void RefreshHistoryWorkerCompleted(HistoryList hist) { if (!PendingClose) { if (hist != null) { OnRefreshCommanders?.Invoke(); history.Clear(); foreach (var ent in hist.EntryOrder) { history.Add(ent); Debug.Assert(ent.MaterialCommodity != null); } history.materialcommodititiesledger = hist.materialcommodititiesledger; history.starscan = hist.starscan; history.shipinformationlist = hist.shipinformationlist; history.CommanderId = hist.CommanderId; if (history.CommanderId != EdsmLogFetcher.CommanderId) { EdsmLogFetcher = new EDSMLogFetcher(history.CommanderId, LogLine); EdsmLogFetcher.OnDownloadedSystems += () => RefreshHistoryAsync(); } ReportProgress(-1, ""); LogLine("Refresh Complete."); RefreshDisplays(); } HistoryRefreshed?.Invoke(this, EventArgs.Empty); // Internal hook call journalmonitor.StartMonitor(); EdsmLogFetcher.Start(); OnRefreshComplete?.Invoke(); // History is completed refreshRequestedFlag = 0; readyForNewRefresh.Set(); } }
// Called on foreground after history has refreshed private void ForegroundHistoryRefreshComplete(HistoryList hist) { Debug.Assert(System.Windows.Forms.Application.MessageLoop); if (!PendingClose) { Debug.WriteLine(BaseUtils.AppTicks.TickCount100 + " Refresh history worker completed"); if (hist != null) { history.Copy(hist); OnRefreshCommanders?.Invoke(); EdsmLogFetcher.StopCheck(); ReportProgress(-1, ""); RefreshDisplays(); Debug.WriteLine(BaseUtils.AppTicks.TickCount100 + " Refresh Displays Completed"); } Debug.WriteLine(BaseUtils.AppTicks.TickCount100 + " JMOn"); journalmonitor.StartMonitor(); Debug.WriteLine(BaseUtils.AppTicks.TickCount100 + " RFcomplete"); OnRefreshComplete?.Invoke(); // History is completed if (history.CommanderId >= 0) { EdsmLogFetcher.Start(EDCommander.Current); } refreshHistoryRequestedFlag = 0; readyForNewRefresh.Set(); LogLine("History refresh complete."); Debug.WriteLine(BaseUtils.AppTicks.TickCount100 + " refresh history complete"); } }
// Called on foreground after history has refreshed private void ForegroundHistoryRefreshCompleteonUI(HistoryList hist) { Debug.Assert(System.Windows.Forms.Application.MessageLoop); if (!PendingClose) { Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Refresh history worker completed"); if (hist != null) { history.Copy(hist); OnRefreshCommanders?.Invoke(); EdsmLogFetcher.StopCheck(); Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Refresh Displays"); OnHistoryChange?.Invoke(history); Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Refresh Displays Completed"); } Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " JM On"); journalmonitor.StartMonitor(true); Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Call Refresh Complete"); OnRefreshComplete?.Invoke(); // History is completed FrontierCAPI.Disconnect(); // Disconnect capi from current user, but don't clear their credential file // available, and not hidden commander, and we have logged in before if (FrontierCAPI.ClientIDAvailable && EDCommander.Current.Id >= 0 && FrontierCAPI.GetUserState(EDCommander.Current.Name) != CAPI.CompanionAPI.UserState.NeverLoggedIn) { System.Threading.Tasks.Task.Run(() => // don't hold up the main thread, do it in a task, as its a HTTP operation { FrontierCAPI.LogIn(EDCommander.Current.Name); // try and get to Active. May cause a new frontier login if (FrontierCAPI.Active) // if active, indicate { LogLine("CAPI User Logged in"); } else { LogLine("CAPI Require Log in"); } }); } if (history.CommanderId >= 0) { EdsmLogFetcher.Start(EDCommander.Current); } refreshHistoryRequestedFlag = 0; readyForNewRefresh.Set(); // say i'm okay for another refresh System.Diagnostics.Debug.WriteLine("Refresh completed, allow another refresh"); LogLine("History refresh complete.".T(EDTx.EDDiscoveryController_HRC)); ReportRefreshProgress(-1, ""); Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Refresh history complete"); } }
internal void HandleIncomingMessage(BreweryMessage message) { LastMessage = DateTime.Now; m_receiptStamps.AddOrUpdate(message.MessageType, m_stopwatch.ElapsedTicks, (messageType, oldValue) => m_stopwatch.ElapsedTicks); try { switch (message.MessageType) { case BreweryMessageType.Settings: Settings = (message as SettingsBreweryMessage).Settings; OnSettingsReceived?.Invoke(this, new BreweryEventArgs() { Brewery = this }); break; case BreweryMessageType.State: RemoteState = (message as StateBreweryMessage).CurrentState; OnStateReceived?.Invoke(this, new BreweryEventArgs() { Brewery = this }); break; case BreweryMessageType.SSIDs: Networks = (message as SsidBreweryMessage).Networks.ToList(); OnNetworksReceived?.Invoke(this, new BreweryEventArgs() { Brewery = this }); break; case BreweryMessageType.AllInfo: AllInfoBreweryMessage allInfo = message as AllInfoBreweryMessage; Settings = allInfo.SettingsMessage().Settings; RemoteState = allInfo.StateMessage().CurrentState; Networks = allInfo.SsidsMessage().Networks.ToList(); OnRefreshComplete?.Invoke(this, new BreweryEventArgs() { Brewery = this }); OnSettingsReceived?.Invoke(this, new BreweryEventArgs() { Brewery = this }); OnNetworksReceived?.Invoke(this, new BreweryEventArgs() { Brewery = this }); OnStateReceived?.Invoke(this, new BreweryEventArgs() { Brewery = this }); break; case BreweryMessageType.Pong: OnPongReceived?.Invoke(this, new BreweryEventArgs() { Brewery = this }); break; case BreweryMessageType.StatusTxt: OnStatusText?.Invoke(this, new BreweryStatusTextEventArgs() { Brewery = this, Message = (message as StatusTextBreweryMessage).Data }); break; case BreweryMessageType.Goodbye: OnGoodbye?.Invoke(this, new BreweryEventArgs() { Brewery = this }); break; } } catch (Exception ex) { Mantis.Error("{0} ignoring brewery delegate exception from message: {1} exception: {2}", ID, message.MessageType, ex); } if (message is IncomingMessage) { try { OnNetworkMessage?.Invoke(this, new BreweryNetworkEventArgs() { Brewery = this, Message = message as IncomingMessage }); } catch (Exception ex) { Mantis.Error("{0} ignoring brewery delegate exception from network delegate, message: {1} exception: {2}", ID, message.MessageType, ex); } } }
public IEnumerator DoRefresh(OnRefreshComplete onComplete) { if (mine) { List<GameObject> mineList = new List<GameObject>(); UniMerge.Util.GameObjectToList(mine, mineList); ObjectMerge.totalRefreshNum = mineList.Count; } if (theirs) { List<GameObject> theirsList = new List<GameObject>(); UniMerge.Util.GameObjectToList(theirs, theirsList); if (theirsList.Count > ObjectMerge.totalRefreshNum) ObjectMerge.totalRefreshNum = theirsList.Count; } ObjectMerge.refreshCount = 0; foreach (IEnumerable e in Refresh()) { yield return e; } if (onComplete != null) onComplete.Invoke(this); }