コード例 #1
0
        private async Task ReconnectToServer()
        {
            Ping p = new Ping();

            while (true)
            {
                try
                {
                    if (PingHost(Config.ConnectionStringEDP, 1433))
                    {
                        try
                        {
                            sqlNotification.ErrorEvent   -= SqlNotification_ErrorEvent;
                            sqlNotification.MessageEvent -= SqlNotification_MessageEvent;
                        }
                        catch
                        { }
                        sqlNotification = new SQL.Server.SqlNotificationDependency();
                        try
                        {
                            sqlNotification.ErrorEvent   += SqlNotification_ErrorEvent;
                            sqlNotification.MessageEvent += SqlNotification_MessageEvent;
                        }
                        catch
                        { }
                    }
                }
                catch
                {
                }
                await Task.Delay(10000);
            }
        }
コード例 #2
0
        private void ServerPage_Loaded(object sender, RoutedEventArgs e)
        {
            Dispatcher.Invoke(() =>
            {
                foreach (var item in ServerSave.Settings)
                {
                    ComplexControl.Items.Add(new ServerSettingsControlViewModel(item.serverid));
                }
            });
            sqlNotification = new SQL.Server.SqlNotificationDependency();

            sqlNotification.MessageEvent += SqlNotification_MessageEvent;
        }