远程设置超时

And*_*der 4 .net c# remoting timeout .net-remoting

.NET远程处理在我的Brownfield应用程序中使用。我们决定为远程处理方法设置超时。

System.Collections.IDictionary properties = new System.Collections.Hashtable();
properties["name"] = Ipc_Channel_Name;
properties["timeout"] = 1 * 1000;

IChannel clientChannel = new IpcClientChannel(properties, null);
ChannelServices.RegisterChannel(clientChannel, false);
Run Code Online (Sandbox Code Playgroud)

问题在于超时似乎不起作用。我通过设置System.Threading.Thread.Sleep(5 * 1000);调用代码来检查它。是IpcClientChannel不支持超时的原因吗?

如何设置超时时间?

Jeh*_*hof 5

设置IpcClientChannel超时的属性的名称不是“ timeout”。名称为“ connectionTimeout”。请参阅客户端通道属性MSDN)。然后它应该工作。

System.Collections.IDictionary properties = new System.Collections.Hashtable();
properties["name"] = Ipc_Channel_Name;
properties["connectionTimeout"] = 1 * 1000;

IChannel clientChannel = new IpcClientChannel(properties, null);
ChannelServices.RegisterChannel(clientChannel, false);
Run Code Online (Sandbox Code Playgroud)