码迷,mamicode.com
首页 > 编程语言 > 详细

27.7 并行语言集成查询(PLinq)

时间:2018-12-31 00:06:02      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:main   查询   性能   code   flag   adk   geo   ring   for   

 

        static void Main()
        {
            ObsoleteMethods(Assembly.Load("mscorlib.dll"));
            Console.ReadKey();
        }
        private static void ObsoleteMethods(Assembly assembly)
        {
            var query = from type in assembly.GetExportedTypes().AsParallel()
                        from method in type.GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.Static)
                        let obsoleteAttrType = typeof(ObsoleteAttribute)
                        where Attribute.IsDefined(method, obsoleteAttrType)
                        orderby type.FullName
                        let obsoleteAttrObj = (ObsoleteAttribute)Attribute.GetCustomAttribute(method, obsoleteAttrType)
                        select string.Format("Type={0} \n Mehthod={1} \n Message={2} \n ", type.FullName, method, obsoleteAttrObj.Message);
            foreach (var item in query)
                Console.WriteLine(item);
            //query.ForAll(a => Console.WriteLine(a));    //让多个线程同时调用Console反而损害性能,因为Console在内部进行线程同步
            //query.Distinct().AsOrdered();
            //query.OrderBy(a => a.Length).AsUnordered();
            //query.WithExecutionMode(ParallelExecutionMode.ForceParallelism);
            //query.WithMergeOptions(ParallelMergeOptions.AutoBuffered);
        }

 

27.7 并行语言集成查询(PLinq)

标签:main   查询   性能   code   flag   adk   geo   ring   for   

原文地址:https://www.cnblogs.com/kikyoqiang/p/10201016.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!