public Task StartAsync(CancellationToken cancellationToken) { return(Task.Run(async() => { await _mqtt.ConnectAsync(_options.BrokerUri, _options.AccessToken); do { if (!HaveModBusConfig) { await _mqtt.RequestAttributes("me", true, "ModBusConfig"); } await _mqtt.UploadAttributeAsync(new { ModBusServiceStatus = "OK" }); Thread.Sleep(TimeSpan.FromSeconds(60)); } while (!cancellationToken.IsCancellationRequested); })); }