Bend.Repl.ReplHandler.workerThread C# (CSharp) Method

workerThread() private method

private workerThread ( ) : void
return void
        private void workerThread()
        {
            ReplState last_state = this.state;
            int error_count = 0;
            while (true) {
                try {
                    workerFunc();
                } catch (Exception e) {
                    error_count++;
                    Console.WriteLine("Server ({0}) exception {1}:\n{2}",
                        ctx.server_guid, error_count, e.ToString());
                    if (error_count > 5) {
                        Console.WriteLine("too many exceptions, shutting down");
                        this.ctx.connector.unregisterServer(ctx.server_guid);
                        this.state = ReplState.shutdown;
                        return;
                    }
                }
                if (this.state != last_state) {
                    Console.WriteLine("++ Server ({0}) changed state {1} -> {2}", ctx.server_guid, last_state, this.state);
                    last_state = this.state;
                }
                if (state == ReplState.shutdown) {
                    Console.WriteLine("worker ending..");
                    return;
                }

                Thread.Sleep(1000);
            }
        }