c#如何使两个方法并行运行

        static void Main(string[] args)
        {
            Parallel.Invoke(Foo, Bar);
        }

        static void Foo()
        {
            Console.WriteLine("foo thread {0}",Thread.CurrentThread.ManagedThreadId);
        }
        static void Bar()
        {
            Console.WriteLine("bar thread {0}",Thread.CurrentThread.ManagedThreadId);
        }

运行结果:

简单方便!!!

posted @ 2016-07-22 16:20  beautifulday  阅读(3017)  评论(0编辑  收藏  举报