public async Task <bool> SendAsync() { bool ok = false; _updateMessage.Enable(false); _updateMessage.UpdateMessageConnection("Validating connection to database!"); await _context.ValidateConnectionAsync().ContinueWith((x) => { if (x.IsCompleted && !x.IsFaulted && !x.IsCanceled) { ok = x.Result; _updateMessage.UpdateMessageConnection(x.Result ? "Correct connection to database!" : "Incorrect connection to database!"); _updateMessage.Enable(x.Result); } }, TaskScheduler.FromCurrentSynchronizationContext()); return(ok); }