public async Task Launch(ILighthouseService service, object launchContext = null)
        {
            service.Initialize(this, launchContext);

            // put the service in a runnable state
            var serviceName = service.ExternalServiceName() ?? service.GetType().Name;

            if (RunningServices.ContainsKey(serviceName))
            {
                throw new Exception($"Service {serviceName} already running");
            }

            RunningServices.TryAdd(serviceName, service);

            // start it, in a separate thread, that will run the business logic for this
            await Task.Run(async() => await service.Start(), CancellationTokenSource.Token).ContinueWith(
                (task) =>
            {
                // handle errors
                if (task.IsFaulted)
                {
                    HandleTaskError(task.Exception.InnerException);
                    throw task.Exception;
                }

                HandleTaskCompletion(service.ToString(), task);
            }, CancellationTokenSource.Token);
        }
示例#2
0
 private void BtnStopAllClick(object sender, RoutedEventArgs e)
 {
     RunningServices.SelectAll();
     BtnStopClick(sender, e);
 }
示例#3
0
 private void UninstallAllClick(object sender, RoutedEventArgs e)
 {
     RunningServices.SelectAll();
     BtnUninstallClick(sender, e);
 }