コード例 #1
0
        public void Execute(JobExecutionContext context)
        {
            try
            {
                //=============================================================================
                log.InfoFormat(AppResource.StartJobExecution, typeof(ContentMontiorFactory).Name);
                //=============================================================================

                // Creek Controller for remote context
                CreekController oController = new CreekController(context.Scheduler);
                // Run the seed monitor jobs & triggers per the registered seeds
                ProcessSeedMonitorForking(context.Scheduler);
                // Run the cotent monitor jobs & triggers per the existing contents
                ProcessContentMonitorForking(context.Scheduler);
                // Export the controller to the remoting context
                ExportRemotingController(oController);

                // Initialize the file system watcher for monitoring the activities of the working directory
                FileSystemWatcher oFSW = new FileSystemWatcher(ContentGenJob.ContentWorkingPath);
                oFSW.EnableRaisingEvents   = false;
                oFSW.IncludeSubdirectories = false;
                oFSW.NotifyFilter          = NotifyFilters.DirectoryName;
                oFSW.Created            += (o, e) => { ProcessContentMonitorForking(context.Scheduler); };
                oFSW.Deleted            += (o, e) => { ProcessContentMonitorForking(context.Scheduler); };
                oFSW.EnableRaisingEvents = true;

                // Wait until the scheduler is shutdown
                int nGCTimeout = 0;
                AutoResetEvent[] oEventNeverSet = new AutoResetEvent[1] {
                    new AutoResetEvent(false)
                };
                while (!context.Scheduler.InStandbyMode)
                {
                    WaitHandle.WaitAny(oEventNeverSet, 3000);
                    nGCTimeout += 3000;
                    if (nGCTimeout >= 5 * 60 * 1000) // GC for every 5 mins
                    {
                        nGCTimeout = 0;              // Reset the timeout
                        GC.Collect(GC.MaxGeneration, GCCollectionMode.Optimized);
                    }
                }

                // Disconnect the controller to the remoting context
                StopRemotingController(oController);

                //=============================================================================
                log.InfoFormat(AppResource.EndJobExecution, typeof(ContentMontiorFactory).Name);
                //=============================================================================
            }
            catch (Exception oEx)
            {
                //===================================================================================================
                log.ErrorFormat(AppResource.JobExecutionFailed, oEx, typeof(ContentMontiorFactory).Name, oEx.Message);
                //===================================================================================================
            }
        }
コード例 #2
0
        private void StopRemotingController(CreekController oController)
        {
            RemotingControllerExporter oExporter = new RemotingControllerExporter();

            oExporter.UnBind(oController);
        }