コード例 #1
0
ファイル: Ping.cs プロジェクト: rotparmna/sydtrucking-payroll
        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);
        }