public Simulator(SimulatorConfiguration configuration, TelemetryClient telemetryClient) { _configuration = configuration; _telemetryClient = telemetryClient; _producerClient = new EventHubProducerClient(_configuration.EventHubConnectionString); }
static public async Task Main(string[] args) { var configuration = new SimulatorConfiguration(); var telemetryClient = InitAppInsights(configuration.AppInsightsKey); var simulator = new Simulator(configuration, telemetryClient); var _cancellationTokenSource = new CancellationTokenSource(); var task = simulator.RunAsync(_cancellationTokenSource.Token); AppDomain.CurrentDomain.ProcessExit += (object?sender, EventArgs e) => { _cancellationTokenSource.Cancel(); }; await task; }