private async void CheckInputs(object sender, ElapsedEventArgs e) { if (busy) { return; } busy = true; currentInputs = hw.ReadInputs(logger); if (currentInputs != previousInputs) { // Report to Engine Console.WriteLine($"Reporting {currentInputs:X8}"); InputReply reply = await client.ReportInputsAsync(new InputValue { Value = currentInputs, Sender = configuration["Name"] }); keepAliveCounter = 0; } previousInputs = currentInputs; // Keep the connection alive if there has been no activity over 100 iterations keepAliveCounter++; if (keepAliveCounter == 100) { await client.KeepInputAliveAsync(new KeepInputAliveMessage { Sender = configuration["Name"] }); keepAliveCounter = 0; } busy = false; }
private static async void CheckInputs(object sender, ElapsedEventArgs e) { //currentInputs = hw.ReadInputs(); //if (currentInputs != previousInputs) { // Report to Engine Console.WriteLine("Reporting"); InputReply reply = await client.ReportInputsAsync(new InputValue { Value = counter }); counter++; } }