private void SetStatus(HttpAsyncHostStatus newStatus)
        {
            HttpAsyncHostStatus oldStatus = Status;

            Status = newStatus;
            StatusChanged?.Invoke(oldStatus, newStatus);
        }
        private void OnStatusChange(HttpAsyncHostStatus oldStatus, HttpAsyncHostStatus newStatus)
        {
            MethodInvoker method = delegate
            {
                if (_server == null || _notifyIcon == null)
                {
                    return;
                }

                SetMenuItems();

                switch (_server.Status)
                {
                case HttpAsyncHostStatus.Initialised:
                    DisplayStatusMessage("Stopped");
                    break;

                case HttpAsyncHostStatus.Running:
                    DisplayStatusMessage("Running");
                    break;

                case HttpAsyncHostStatus.Starting:
                    DisplayStatusMessage("Starting", false);
                    break;

                case HttpAsyncHostStatus.Uninitialised:
                    DisplayStatusMessage("Not Ready", false);
                    break;

                //case HttpAsyncHostStatus.Error:
                //    DisplayStatusMessage("Error occurred, check logs", true, ToolTipIcon.Error);
                //    break;
                default:
                    DisplayStatusMessage("Unrecognized status code", true, ToolTipIcon.Error);
                    break;
                }
                _notifyIcon.Icon = AppIcon;
            };

            if (_notifyIcon != null && _notifyIcon.ContextMenuStrip.InvokeRequired)
            {
                _notifyIcon.ContextMenuStrip.Invoke(method);
            }
            else
            {
                method.Invoke();
            }
        }