コード例 #1
0
        /// <summary>
        /// 监控多张SSB表,每个表开启一个线程来处理
        /// </summary>
        /// <param name="jobContext"></param>
        /// <param name="processConfig"></param>
        private static void MultiChannelProcess(JobContext jobContext, SSBProcessConfig processConfig)
        {
            List <string> logs = new List <string>();

            using (ThreadWaitHandle handler = new ThreadWaitHandle(processConfig.SSBChannels.Count))
            {
                for (int i = 0; i < processConfig.SSBChannels.Count; i++)
                {
                    SSBChannel channel = processConfig.SSBChannels[i];
                    ThreadPool.QueueUserWorkItem((object obj) =>
                    {
                        try
                        {
                            SSBProcessBase processer = SSBProcessFactory.Create(channel);
                            processer.RunProcess();

                            lock (logs)
                            {
                                logs.AddRange(processer.Logs);
                            }
                        }
                        finally
                        {
                            handler.ReleaseOne();
                        }
                    });
                }
            }

            OutPutLog(logs, jobContext);
        }
コード例 #2
0
        /// <summary>
        /// 处理单张SSB表
        /// </summary>
        /// <param name="jobContext"></param>
        /// <param name="processConfig"></param>
        private static void SingleChannelProcess(JobContext jobContext, SSBProcessConfig processConfig)
        {
            SSBProcessBase processer = SSBProcessFactory.Create(processConfig.SSBChannels[0]);

            processer.RunProcess();

            OutPutLog(processer.Logs, jobContext);
        }