private async void InitSignalR() { connection = new HubConnectionBuilder() .ConfigureLogging(loggingBuilder => { loggingBuilder.SetMinimumLevel(LogLevel.Debug); loggingBuilder.ToString(); }) .WithUrl(UrlPi) .Build(); connection.Closed += async(error) => { await Task.Delay(new Random().Next(0, 5) * 1000); await connection.StartAsync(); }; connection.On <bool, bool>("Status", (motorstate, boosterstate) => { motorState = motorstate; boosterState = boosterstate; if (Motor.State != motorState) { Motor.Actuate(motorState); } if (Booster.State != boosterState) { Booster.Actuate(boosterState); } }); await connection.StartAsync(); await connection.InvokeAsync("GetStates"); }