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);
        }

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

简单方便!!!

相关文章:

  • 2021-11-29
  • 2021-08-19
  • 2021-10-13
  • 2022-12-23
  • 2022-12-23
  • 2021-08-14
  • 2021-11-29
  • 2021-09-26
猜你喜欢
  • 2022-01-11
  • 2022-12-23
  • 2022-02-14
  • 2022-01-02
  • 2022-01-20
  • 2021-07-11
  • 2022-01-02
相关资源
相似解决方案