zoukankan      html  css  js  c++  java
  • 27.7 并行语言集成查询(PLinq)

            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} 
     Mehthod={1} 
     Message={2} 
     ", 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);
            }
  • 相关阅读:
    MySQL 修改数据
    Scala 简介
    tensorflow mnist read_data_sets fails
    Mac安装Homebrew
    MySQL 创建数据表
    MySQL 数据类型
    wc--Linux
    xxx is not in the sudoers file.This incident will be reported.的解决方法
    linux centos下安装dokuwiki
    CentOS修改系统时间
  • 原文地址:https://www.cnblogs.com/kikyoqiang/p/10201016.html
Copyright © 2011-2022 走看看