/// <summary> /// <para> /// Synchronizes the UI state with the current cluster configuration. /// </para> /// <note> /// This method is somewhat special in that it must be executed on the UI /// thread and if it's called on another thread, then the method will post /// a message to itself to invoke itself shortly on the UI thread. /// </note> /// </summary> public async Task UpdateUIStateAsync() { if (InvokeRequired) { PostUpdateUIState(); return; } KubeHelper.LoadConfig(); await UpdateProxiesAsync(); if (InErrorState) { return; } if (!operationInProgress) { notifyIcon.Icon = IsConnected ? connectedIcon : disconnectedIcon; if (notifyStack.Count > 0 && !string.IsNullOrEmpty(notifyStack.Peek().BalloonText)) { SetBalloonText(notifyStack.Peek().BalloonText); } else if (IsConnected) { SetBalloonText($"{Text}: {KubeHelper.CurrentContextName}"); } else { SetBalloonText($"{Text}: disconnected"); } } else if (remoteOperation != null && NeonHelper.GetProcessById(remoteOperation.ProcessId) == null) { // The original [neon-cli] process is no longer running; // it must have terminated before signalling the end // of the operation. We're going to clear the operation // status. // // This is an important fail-safe. StopOperation(); return; } }