using System.Threading.Tasks;   
class Test
{
    static int N = 1000;

    static void TestMethod()
    {
        // Using a named method.
        Parallel.For(0, N, Method2);

        // Using an anonymous method.
        Parallel.For(0, N, delegate(int i)
        {
            // Do Work.
        });

        // Using a lambda expression.
        Parallel.For(0, N, i =>
        {
            // Do Work.
        });
    }

    static void Method2(int i)
    {
        // Do work.
    }
}

 

相关文章:

  • 2021-09-27
  • 2021-10-29
  • 2022-12-23
  • 2021-12-21
  • 2021-07-18
  • 2022-01-12
  • 2022-01-12
猜你喜欢
  • 2021-12-22
  • 2022-12-23
  • 2022-02-13
  • 2022-12-23
  • 2021-11-25
  • 2021-05-19
  • 2021-12-08
相关资源
相似解决方案