protected void SelectLoop()
{
Thread.CurrentThread.Name = "tcp_select_thread";
//No one can see this except this thread, so there is no
//need for thread synchronization
SocketState ss = new SocketState(this);
ss.TAA = _ta_auth;
if( ProtocolLog.Monitor.Enabled ) {
// log every 5 seconds.
ActionQueue.Enqueue(new LogAction(new TimeSpan(0,0,0,0,5000), ActionQueue));
}
//Start the select action:
ActionQueue.Enqueue(new SelectAction(this));
bool got_action = false;
while(ss.Run) {
SocketStateAction a = ActionQueue.TryDequeue(out got_action);
if( got_action ) { a.Start(ss); }
}
ShutdownAction sda = new ShutdownAction(this);
sda.Start(ss);
//Empty the queue to remove references to old objects
do {
ActionQueue.TryDequeue(out got_action);
} while(got_action);
}