public async Task StopServerAsync()
 {
     if (StopAsync != null)
     {
         await StopAsync.InvokeAsync(this, EventArgs.Empty);
     }
 }
Exemplo n.º 2
0
        private async Task StartStopRestartAsync(bool isReload)
        {
            try {
                if (isReload)
                {
                    isReloading = true;
                }
                OnStopping();
                await StopAsync?.InvokeAsync(this, EventArgs.Empty);

                OnStopped();
                await StartAsync?.InvokeAsync(this, EventArgs.Empty);

                var componentModel = ServiceProvider.GetService(typeof(SComponentModel)) as IComponentModel;
                Assumes.Present(componentModel);

                var agentService = componentModel.GetService <ICodeStreamAgentService>();
                await agentService.ReinitializeAsync();

                Interlocked.Exchange(ref _state, 1);
                Log.Debug($"SetState={_state}");
            }
            catch (NullReferenceException ex) {
                Log.LocalWarning(ex?.Message);
            }
            catch (Exception ex) {
                Log.Error(ex, nameof(RestartAsync));
            }
            finally {
                if (isReload)
                {
                    isReloading = false;
                }
            }
            await Task.CompletedTask;
        }