/// <summary> /// This is the main entry point for your service instance. /// </summary> /// <param name="cancellationToken">Canceled when Service Fabric needs to shut down this service instance.</param> protected override async Task RunAsync(CancellationToken cancellationToken) { bool initialised = false; try { _logger.LogInfo("NCS Stateless Service Started"); _jobContextManager.OpenAsync(cancellationToken); Debug.WriteLine("Started"); initialised = true; await Task.Delay(Timeout.Infinite, cancellationToken); } catch (Exception exception) when(!(exception is TaskCanceledException)) { // Ignore, as an exception is only really thrown on cancellation of the token. _logger.LogError("NCS Stateless Service Exception", exception); } finally { if (initialised) { await _jobContextManager.CloseAsync(); _logger.LogInfo("NCS Stateless Service Ended"); } } }
protected override async Task RunAsync(CancellationToken cancellationToken) { var initialised = false; try { logger.LogDebug("Starting the Earning Events service."); jobContextManager = lifetimeScope.Resolve <IJobContextManager <JobContextMessage> >(); jobContextManager.OpenAsync(cancellationToken); initialised = true; logger.LogInfo("Started the Earning Events service."); await Task.Delay(Timeout.Infinite, cancellationToken); } catch (Exception exception) when(!(exception is TaskCanceledException)) { // Ignore, as an exception is only really thrown on cancellation of the token. logger.LogError($"Reference Data Stateless Service Exception. Error: {exception}.", exception); } finally { if (initialised) { logger.LogInfo("Earning Events Stateless Service End"); await jobContextManager.CloseAsync(); } } }
public async Task RunAsync(CancellationToken cancellationToken) { var initialised = false; try { logger.LogDebug("Starting the Job Context Manager service."); jobContextManager.OpenAsync(cancellationToken); initialised = true; logger.LogInfo("Started the Job Context Manager service."); await Task.Delay(Timeout.Infinite, cancellationToken); } catch (Exception exception) when(!(exception is TaskCanceledException)) { logger.LogError($"Error running DC job context manager. Error: {exception.Message}.", exception); throw; } finally { if (initialised) { logger.LogDebug("Closing the job context manager."); await jobContextManager.CloseAsync(); logger.LogInfo("Closed job context manager."); } } }
protected override async Task RunAsync(CancellationToken cancellationToken) { bool initialised = false; try { _jobContextManager.OpenAsync(cancellationToken); initialised = true; await Task.Delay(Timeout.Infinite, cancellationToken); } catch { // Ignore, as an exception is only really thrown on cancellation of the token. } finally { if (initialised) { await _jobContextManager.CloseAsync(); } } }