Npgsql.NpgsqlConnector.NpgsqlContextHolder.ProcessServerMessages C# (CSharp) Method

ProcessServerMessages() private method

private ProcessServerMessages ( ) : void
return void
            internal void ProcessServerMessages()
            {
                try
                {
                    while (true)
                    {
                        // Mono's implementation of System.Threading.Monitor does not appear to give threads
                        // priority on a first come/first serve basis, as does Microsoft's.  As a result, 
                        // under mono, this loop may execute many times even after another thread has attempted
                        // to lock on _socket.  A short Sleep() seems to solve the problem effectively.
                        // Note that Sleep(0) does not work.
                        Thread.Sleep(1);

                        lock (connector._socket)
                        {
                            // 20 millisecond timeout
                            if (this.connector.Socket.Poll(20000, SelectMode.SelectRead))
                            {
                                this.connector.ProcessAndDiscardBackendResponses();
                            }
                        }
                    }
                }
                catch (IOException ex)
                {
                    this.connector._notificationException = ex;
                }

            }
        }
NpgsqlConnector.NpgsqlContextHolder