呵.现在贴代码!
1,后台处理管理对象
public class BkExecManager
{
//定时回调。
private static TimerCallback timerDelegate;
private static Timer stateTimer;
private static BkExecer m_Execer;
public static string DataPath;
public static string BkManager = "XXXX";
public static int BkBufSize = 100;
private static int Interval = 10000;
public static BkExecer Execer
{
get { return m_Execer; }
}
static BkExecManager()
{
DataPath = System.AppDomain.CurrentDomain.BaseDirectory + "BkItem\";
if (System.Configuration.ConfigurationManager.AppSettings["Interval"] != null)
Interval = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["Interval"]);
if (System.Configuration.ConfigurationManager.AppSettings["BkBufSize"] != null)
BkBufSize = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["BkBufSize"]);
if (System.Configuration.ConfigurationManager.AppSettings["BkManager"] != null)
BkManager = System.Configuration.ConfigurationManager.AppSettings["BkManager"];
m_Execer = new BkExecer();
//初始化回调
timerDelegate = new TimerCallback(m_Execer.DoBkExec);
//初始化定时器
stateTimer = new Timer(timerDelegate, null, 5000, Interval);
}
/**//// <summary>
/// 停止定时器.
/// </summary>
static void BkExecQuit()
{
stateTimer.Dispose();
}
}
2,后台处理执行
public class BkExecer
{
//维护一个前进前出的队列。
private Queue<ExecItem> m_BkExecItemList;
private static object lockHelper = new object();
private static bool m_IsBusy = false;
public static bool IsBusy
{
get { return m_IsBusy; }
}
public BkExecer()
{
m_BkExecItemList = new Queue<ExecItem>(BkExecManager.BkBufSize);
/**/////读入待处理