private void QueryProcess() { //if (m_dblog) //{ // m_LogWriterExt = // new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "DbLogs" + Path.DirectorySeparatorChar // + m_Name + "_" + DateTime.Now.ToString("yyyy-MM-dd") + "_ext.log", true); //} Action <DataSet> null_action = (ds) => { }; m_Logger.Info("{0} thread start", Thread.CurrentThread.Name); while (Status == DbStatus.Running) { Interlocked.Increment(ref m_CallingItemsCount); KeyValuePair <DateTime, DBReadItem> item; if (m_QueryWorkItems.TryDequeue(out item)) { Action <DataSet> callback = item.Value.CallBack != null ? item.Value.CallBack : null_action; DataSet ds = null; Performance.Record( item.Value.SQL, item.Value.GroupName, () => { try { ds = m_Provider.Query(m_QueryConnString, item.Value.SQL); } catch (Exception ex) { m_Logger.Error(item.Value.SQL + Environment.NewLine, ex); } }, MonitoringType.DBExcute); m_CallBackItems.Enqueue(item.Key, new DBCallBackItem() { GroupName = item.Value.GroupName, CallBack = callback, Data = ds, Name = item.Value.SQL }); Interlocked.Increment(ref m_QueriedItemsCount); Interlocked.Decrement(ref m_CallingItemsCount); } else { Interlocked.Decrement(ref m_CallingItemsCount); Thread.Sleep(IDLE_SLEEP_MILISECONDS); } } if (m_LogWriterExt != null) { m_LogWriterExt.Close(); m_LogWriterExt = null; } Log.InfoFormat("{0} query thread stop", Thread.CurrentThread.Name); }