使用 jQuery 在网页上调用 WebMethod 时。我们将其定义为静态。
然而static methods always have one instance。发出多个 Web 请求时会发生什么。
- 它真的是异步发生的还是
- 所有请求都流水线等待 WebMethod 接受请求?
我创建了一个示例控制台程序来模拟场景static method work并发现它们按顺序执行。
class Program
{
    static int count = 10;
    static void Main(string[] args)
    {
        new Program().foobar();
        Console.ReadLine();
    }
    public void foobar()
    {
        Parallel.Invoke(() => work("one"), () => work("two"), () => work("three"), ()=> work("four"));
    }
    static void work(string str)
    {
        Thread.Sleep(3000);
        count++; 
        Console.WriteLine(str + " " + count);
    }
}
你能解释一下这个概念吗?