Exemplo n.º 1
0
        private void healthChecker()
        {
            while (isConnected)
            {
                if (this.refreshStack.Count > 0)
                {
                    lock (this.refreshStack.SyncRoot)
                    {
                        if (this.refreshStack.Count > 0)
                        {
                            DatabaseClient toReCheck;
                            List<DatabaseClient> failedClients = new List<DatabaseClient>(this.refreshStack.Count);
                            while (this.refreshStack.Count > 0)
                            {
                                toReCheck = this.refreshStack.Dequeue() as DatabaseClient;
                                toReCheck.disconnect();
                                toReCheck.Dispose();
                                toReCheck = new DatabaseClient(this, toReCheck.getID());
                                try
                                {
                                    toReCheck.connect();

                                    reportDone(toReCheck);
                                }
                                catch (Exception ex)
                                {
                                    failedClients.Add(toReCheck);
                                    Out.writeSeriousError("Exception while reconencting client [" + toReCheck.getID() + "] Message was -> " + ex.Message);
                                }
                            }
                            foreach (DatabaseClient client in failedClients)
                            {
                                this.refreshStack.Enqueue(client);
                            }
                        }
                    }
                }
                Thread.Sleep(100);

            }
        }
Exemplo n.º 2
0
        private void healthChecker()
        {
            while (isConnected)
            {
                if (this.refreshStack.Count > 0)
                {
                    lock (this.refreshStack.SyncRoot)
                    {
                        if (this.refreshStack.Count > 0)
                        {
                            DatabaseClient        toReCheck;
                            List <DatabaseClient> failedClients = new List <DatabaseClient>(this.refreshStack.Count);
                            while (this.refreshStack.Count > 0)
                            {
                                toReCheck = this.refreshStack.Dequeue() as DatabaseClient;
                                toReCheck.disconnect();
                                toReCheck.Dispose();
                                toReCheck = new DatabaseClient(this, toReCheck.getID());
                                try
                                {
                                    toReCheck.connect();

                                    reportDone(toReCheck);
                                }
                                catch (Exception ex)
                                {
                                    failedClients.Add(toReCheck);
                                    Out.writeSeriousError("Exception while reconencting client [" + toReCheck.getID() + "] Message was -> " + ex.Message);
                                }
                            }
                            foreach (DatabaseClient client in failedClients)
                            {
                                this.refreshStack.Enqueue(client);
                            }
                        }
                    }
                }
                Thread.Sleep(100);
            }
        }