public static BackgroundTestService GetInstance() { Console.WriteLine("GetInstance(): " + DateTime.Now.ToString("dd-MM-yyyy hh:mm:ss")); if (_connection == null) { _connection = new HubConnectionBuilder() .WithUrl("https://chatwebapi.azurewebsites.net//TesteHub") //.AddMessagePackProtocol() .Build(); } if (_connection.State == HubConnectionState.Disconnected) { _connection.StartAsync(); } _connection.Closed += async(error) => { await Task.Delay(5000); await _connection.StartAsync(); }; if (_instance == null) { _instance = new BackgroundTestService(); } return(_instance); }
public async Task <bool> StartJob() { BackgroundTestService.GetInstance(); Console.WriteLine("TESTE: " + DateTime.Now.ToString("dd-MM-yyyy hh:mm:ss")); //Return true para continuar return(true); //Return false para parar //return false; }