WCF服务端的执行问题 楼主 A=yes B=no 是期望结果, 因为A在等待的同时 B已经跑完了 而B直接跑line 15 = no, A 5秒后=yes 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可是B在调用的时候,iTest 还是 6000,应该返回Yes啊 从结果的log 你是怎么知道 A比B先执行的?1 是A 还是B 怎么确认的呢, 你调试了?1 In 1620001 Out1620052 In 1620052 Out162005 1是A,因为A在调用时,我就是用1去调用的,B是用2去调用的。 如果没有给A和B各开一个线程处理,那么执行完A才执行B是期望的结果. 即使你用的是异步调用,但是其实用的是同一个线程.如果你处理完A的数据立即返回,那么A和B看起来就是都在通信,似乎互相没有影响.但是如果执行SLEEP阻塞了线程,就会有影响 明显是单线程的执行结果,检查你这方法是不是在某个地方被lock了 多谢各位的回复,这是我做的一个测试,就是想看看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(); 不知道你想干什么。 如果是针对同一条数据,就用 for update。当一个用户使用的时候,另一个自动排队。如果针对多条数据就不用考虑这么多了,同时进行也好,分开进行也好,都不是处理的同一个东西。 跪求.net 3.5类库(免在线下载安装) 写了个类,在Console里面高仿win7复制文件提示覆盖选项 水晶报表的问题(立即给分) 如何将文件扩展名和系统图标关联在一起? form切換問題 datagrideview 中用comboxcolumn时进行databind时出错 帮个忙,我想在datagrid中获得,首记录,上一条记录,下一条记录,最后一条记录.如何做呢. c#如何实现抓取底层数据包 如何取得硬盘序列号。 做了个绘制统计图(柱形图和扇形图)的class,与大家共同研究 恳请指教:帮忙写一个修改DataTable列名的类 C# 可不可以代码实现禁止一个进程访问网络
1 是A 还是B 怎么确认的呢, 你调试了?1 In 1620001 Out1620052 In 1620052 Out162005
如果你处理完A的数据立即返回,那么A和B看起来就是都在通信,似乎互相没有影响.
但是如果执行SLEEP阻塞了线程,就会有影响
不过我原来想象的,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();