private void ProcessFlush()
{
//only process if we have delegate function assignment
if (p_FpDelegate != null)
{
//we have to wait until previous flush completes before flushing or until our timeout has expired
if (p_FlushInProgress != null)
{
int maxWaitCount = (BonCodeAJP13Settings.BONCODEAJP13_FLUSH_TIMEOUT * 1000) / 50;
int i = 0;
if (p_Logger != null) p_Logger.LogMessage("flush in progress detected. waiting.", BonCodeAJP13LogLevels.BONCODEAJP13_LOG_BASIC);
while (p_FlushInProgress() && i < maxWaitCount)
{
i++;
Thread.Sleep(50); //wait 50 miliseconds for flush to complete
}
}
//pass on the packets received to delegate function for processing
p_FpDelegate(p_PacketsReceived);
//Delete all packets processed so far
p_PacketsReceived.Clear();
}
}