Ejemplo n.º 1
0
        public void RunProcess(Action process, PriorityClass priorityClass, string processName, bool runInThread)
        {
            process = TaskInProgress.Start(this, process, $"RunProcess[{processName}]");
            LogTileMessage($"Starting Process '{processName}'...");

            if (runInThread)
            {
                process();
            }
            else
            {
                PriorityScheduler.Schedule(process, priorityClass, Centroid);
            }
        }
Ejemplo n.º 2
0
        static void TestPriorityScheduler()
        {
            IScheduler scheduler = new PriorityScheduler(2);

            scheduler.Start();

            Console.WriteLine("Adding task 1");
            scheduler.Schedule(() => System.Threading.Thread.Sleep(1000), 2.0f);
            Console.WriteLine("Adding task 2");
            scheduler.Schedule(() => System.Threading.Thread.Sleep(1000), 2.0f);
            Console.WriteLine("Adding task 3");
            scheduler.Schedule(() => Console.WriteLine("Hello, world! (Lower priority)"), 2.0f);
            Console.WriteLine("Adding task 4");
            scheduler.Schedule(() => Console.WriteLine("Hello, world! (Higher priority)"), 1.0f);

            Console.ReadKey();
        }
Ejemplo n.º 3
0
        public bool Load(TilePos index, Action <bool, Tile> action)
        {
            var(existed, tile) = _tileManager.GetOrCreateTile(index);
            if (existed)
            {
                action(true, tile);
                return(true);
            }

            PriorityScheduler.Schedule(() =>
            {
                using (Profiler.CurrentProfiler.Begin("Loading Tile From Disk"))
                {
                    _storage.TryLoadTile(tile, loaded =>
                    {
                        action(false, tile);
                    });
                }
            }, PriorityClass.Average, -1);
            return(false);
        }
Ejemplo n.º 4
0
 private static void Main(string[] args)
 {
     container.RegisterInstance<MangaCrawlParameter>(MangaCrawler.GetParameters("mangascanner.ini"));
     var taskSchedule = new PriorityScheduler(System.Threading.ThreadPriority.Lowest);
     var taskFactory = new TaskFactory(taskSchedule);
     var task = taskFactory.StartNew(() =>
     {
         var timespan = MangaCrawler.Crawl();
         Console.WriteLine(String.Format("======== {0}", timespan.TotalHours));
         Console.ReadLine();
     });
     task.Wait();
 }