當前位置: 首頁>>代碼示例>>C#>>正文


C# ActorSystem.Dispose方法代碼示例

本文整理匯總了C#中ActorSystem.Dispose方法的典型用法代碼示例。如果您正苦於以下問題:C# ActorSystem.Dispose方法的具體用法?C# ActorSystem.Dispose怎麽用?C# ActorSystem.Dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ActorSystem的用法示例。


在下文中一共展示了ActorSystem.Dispose方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

        static void Main(string[] args)
        {
            ResizerActors = ActorSystem.Create("ResizerActors");
            var commanderActor = ResizerActors.ActorOf(Props.Create(() => new CommanderActor()));

               var imagePath = args[0];

            var profileDictionary = new Dictionary<string, int>
            {
                { "Icon-40.png", 40 },
                { "Icon-40-2x.png", 80 },
                { "Icon-60.png", 60 },
                { "Icon-60-2x.png", 60 },
                {"Icon-72.png",72},
                {"Icon-72-2x.png",144},
                {"Icon-76.png",76},
                {"Icon-76-2x.png", 152},
                {"Icon-Small-50.png", 50},
                { "Icon-Small-50-2x.png", 100},
                { "Icon-Small.png", 29},
                { "Icon-Small-2x.png", 58},
                { "Icon.png", 57},
                { "Icon-2x.png", 114},
                { "iTunesArtwork.png", 512},
                { "iTunesArtwork-2x.png", 1024},
                { "Icon-16.png", 16},
                { "Icon-24.png", 24},
                { "Icon-32.png", 32},
                { "Icon-64.png", 64},
                { "Icon-120.png", 120},
                { "Icon-152.png", 152},
                { "Icon-Small-40.png", 40},
                { "Icon-Small-40-2x.png", 80},
                { "Icon-60-3x.png", 180},
                { "Icon-Small-3x.png", 87},
                { "Icon-Small-40-3x.png", 120}
            };
            //var allTasks = profileDictionary.Keys.Select(key =>
            //{
            //    return Task<Tuple<string, Stream>>.Factory.StartNew(() => Save(new Bitmap(imagePath), profileDictionary[key], profileDictionary[key], 1, key));
            //});

            //Task.WaitAll(allTasks.ToArray());

            //var results = allTasks.Select(x => x.Result).ToArray();

            //CreateToMemoryStream(results, "test.zip");

            byte[] originalImage;
            using (var fs = File.OpenRead(imagePath))
            {
                originalImage = new byte[fs.Length];
                fs.Read(originalImage, 0, (int)fs.Length);
            }

            //coordinatorActor.Tell(new CoordinatorActor.ResizeImage(originalImage, profileDictionary, "test.zip"));
            var command = Console.ReadLine();
            while(command == "")
            {
                //Task.Run(() => {
                //    Parallel.For(0, 10, index => {
                //        //var coordinatorActor = ResizerActors.ActorOf(Props.Create(() => new CoordinatorActor()));
                //        commanderActor.Tell(new CoordinatorActor.ResizeImage(originalImage, profileDictionary, string.Format("{0}.zip", Guid.NewGuid())));
                //    });
                //});
                commanderActor.Tell(new CoordinatorActor.ResizeImage(originalImage, profileDictionary, string.Format("{0}.zip", Guid.NewGuid())));

                command = Console.ReadLine();
            }

            ResizerActors.Shutdown();
            ResizerActors.Dispose();
        }
開發者ID:BredStik,項目名稱:ImageResizer,代碼行數:73,代碼來源:Program.cs


注:本文中的ActorSystem.Dispose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。