楼主 A=yes  B=no 是期望结果, 因为A在等待的同时 B已经跑完了 而B直接跑line 15 = no, A 5秒后=yes

解决方案 »

  1.   

    可是B在调用的时候,iTest 还是 6000,应该返回Yes啊
      

  2.   

    从结果的log 你是怎么知道 A比B先执行的?
    1 是A 还是B 怎么确认的呢,  你调试了?1 In 1620001 Out1620052 In 1620052 Out162005
      

  3.   

    1是A,因为A在调用时,我就是用1去调用的,B是用2去调用的。
      

  4.   

    如果没有给A和B各开一个线程处理,那么执行完A才执行B是期望的结果.
      

  5.   

    即使你用的是异步调用,但是其实用的是同一个线程.
    如果你处理完A的数据立即返回,那么A和B看起来就是都在通信,似乎互相没有影响.
    但是如果执行SLEEP阻塞了线程,就会有影响
      

  6.   

    明显是单线程的执行结果,检查你这方法是不是在某个地方被lock了
      

  7.   

    多谢各位的回复,这是我做的一个测试,就是想看看WCF内部的运行机制.
    不过我原来想象的,WCF作为服务的时候,多个客户端连接进来,每个连接相关调用的函数是同步执行的,
    看结果好像不是这样,听各位的意思好像也不是同步执行的,如果我想实现每个连接相关调用的函数是同步执行的,
    也就是多线程操作,应该进行什么设置?
    下面是我建立WCF服务的代码,请各位指教一下:                    System.ServiceModel.NetTcpBinding oBinding = new NetTcpBinding();
                        oBinding.Name = "tcpbinding";
                        oBinding.TransactionFlow = false;   //是否支持分布式事务
                        oBinding.TransferMode = TransferMode.Buffered;
                        oBinding.TransactionProtocol = TransactionProtocol.OleTransactions;
                        oBinding.ReceiveTimeout = new TimeSpan(168, 10, 10);
                        oBinding.SendTimeout = new TimeSpan(168, 10, 10);
                        oBinding.OpenTimeout = new TimeSpan(168, 10, 10);
                        oBinding.CloseTimeout = new TimeSpan(168, 10, 10);
                        oBinding.MaxReceivedMessageSize = 2147483647;
                        oBinding.MaxBufferPoolSize = 2147483647;
                        oBinding.MaxBufferSize = 2147483647;
                        oBinding.MaxConnections = 500;                    ServiceThrottlingBehavior oThrottlingBehavior = oServiceHost.Description.Behaviors.Find<ServiceThrottlingBehavior>();
                        if (null == oThrottlingBehavior)
                        {
                            oThrottlingBehavior = new ServiceThrottlingBehavior();
                            oServiceHost.Description.Behaviors.Add(oThrottlingBehavior);
                        }
                        oThrottlingBehavior.MaxConcurrentCalls = 500;
                        oThrottlingBehavior.MaxConcurrentInstances = 500;
                        oThrottlingBehavior.MaxConcurrentSessions = 500;                    oBinding.Security.Mode = SecurityMode.None;
                        oBinding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;                    oServiceHost.AddServiceEndpoint(typeof(Star.BusinessServiceInterface.IObjectMaster), oBinding, "net.tcp://localhost:9999/ObjectMaster");                    oServiceHost.Open();
      

  8.   

    不知道你想干什么。 如果是针对同一条数据,就用 for update。当一个用户使用的时候,另一个自动排队。如果针对多条数据就不用考虑这么多了,同时进行也好,分开进行也好,都不是处理的同一个东西。