和remoting通信,建立信道设置超时的问题。

xieqi 2010-12-16 10:28:42
网上看到调用remoting设置超时的方法。
TcpChannel liebiao_tcpChannel;
if (liebiao_tcpChannel == null)
{
Hashtable props = new Hashtable();
props["name"] = "tcp_timeout1";
props["timeout"] = 3000;
liebiao_tcpChannel = new TcpChannel(props, null, null);
ChannelServices.RegisterChannel(liebiao_tcpChannel, false);
}
Remoting_function remoteobj = (Remoting_function)Activator.GetObject(typeof(Remoting_function), liebiao_url);
这个设置方法运行3秒就超时,没问题。
但是如果我有2个remoting。我调用2个设置超时不一样就不行了。
TcpChannel liebiao_tcpChannel2;
if (liebiao_tcpChannel2 == null)
{
Hashtable props = new Hashtable();
props["name"] = "tcp_timeout2";
props["timeout"] = 6000;
liebiao_tcpChannel2 = new TcpChannel(props, null, null);
ChannelServices.RegisterChannel(liebiao_tcpChannel2, false);
}
Remoting_function2 remoteobj2 = (Remoting_function2)Activator.GetObject(typeof(Remoting_function2), liebiao_url2);
这样不管掉哪个remoting,超时要么全是3秒,要么全是6秒。重启iis后,先调remoteobj2 的方法,再调remoteobj ,超时全是6秒。重启iis后,反过来先调remoteobj 的方法,超时就全3秒。

下面是查看信道。确实开了2个。
System.Runtime.Remoting.Channels.IChannel[] myIChannelArray = System.Runtime.Remoting.Channels.ChannelServices.RegisteredChannels;
for (int i = 0; i < myIChannelArray.Length; i++)
{
Response.Write("Name of Channel: "+ myIChannelArray[i].ChannelName);
Response.Write("Priority of Channel: "+myIChannelArray[i].ChannelPriority);
}
Name of Channel: tcp_timeout1Priority of Channel: 1
Name of Channel: tcp_timeout2Priority of Channel: 1

怎么才能使2个超时设置各用各的呢?
...全文
151 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧