BUG:The channel 'tcp' is already registered.
来源:互联网 发布:linux添加路由命令 编辑:程序博客网 时间:2024/05/18 00:10
稳定重现bug的程序:
class Program { static void Main(string[] args) { System.Threading.Thread[] threads = new System.Threading.Thread[2]; threads[0] = new System.Threading.Thread(new ThreadStart(GetConnectionManager)); threads[1] = new System.Threading.Thread(new ThreadStart(GetConnectionManager)); threads[0].Start(); threads[1].Start(); Console.ReadKey(); } static private void GetConnectionManager() { lock (typeof(Program)) { bool hasTcpChannel = false; foreach (var item in ChannelServices.RegisteredChannels) { if (item is TcpClientChannel) { hasTcpChannel = true; } } if (!hasTcpChannel) { IChannel clientChannel = new TcpClientChannel(); Thread.Sleep(2000); ChannelServices.RegisterChannel(clientChannel, false); } } } }
我们的解决方案是:
class Program { static void Main(string[] args) { System.Threading.Thread[] threads = new System.Threading.Thread[2]; threads[0] = new System.Threading.Thread(new ThreadStart(GetConnectionManager)); threads[1] = new System.Threading.Thread(new ThreadStart(GetConnectionManager)); threads[0].Start(); threads[1].Start(); Console.ReadKey(); } static private void GetConnectionManager() { //加锁来保证线程安全 lock (typeof(Program)) { bool hasTcpChannel = false; foreach (var item in ChannelServices.RegisteredChannels) { if (item is TcpClientChannel) { hasTcpChannel = true; } } if (!hasTcpChannel) { IChannel clientChannel = new TcpClientChannel(); Thread.Sleep(2000); ChannelServices.RegisterChannel(clientChannel, false); } } }
- BUG:The channel 'tcp' is already registered.
- jboss xxx is already registered
- XRecyclerView框架中所遇到的bug,.XRecyclerView$DataObserver@3f43b8 is already registered
- CRS-2728: A resource type with the name 'ora.daemon.type' is already registered
- kafka : A broker is already registered on the path /brokers/ids/1006. This proba
- dojo id is already registered 解决
- Debian: Driver 'pcspkr' is already registered, aborting
- The system is not registered with rhn
- What is the LFE (.1) Channel
- the vfpoledb provider is not registered on the local machine
- 【rabbitmq】 com.rabbitmq.client.AlreadyClosedException: channel is already closed due to channel erro
- There is no build provider registered for the extension '.cshtml'.
- ovirt4 The redirection URI for client is not registered
- 警告处理 A C3P0Registry mbean is already registered. This probably means that an application using c3p.
- Vaadin java.lang.RuntimeException: A connector with id # is already registered!
- 警告处理 A C3P0Registry mbean is already registered. This probably means that an application using c3p.
- Jboss添加数据源出现Service jboss.jdbc-driver.mysql is already registered错误
- 警告: A C3P0Registry mbean is already registered. This probably means that an application...
- 【转】ubuntu server 安装VPN pptp
- cygwin下的vim,Backsapce和方向键不好使解决办法。
- Sql Server数据库向Oracle数据库的迁移方法
- English1
- Linux内核学习-概念解释-linux硬链接与软链接
- BUG:The channel 'tcp' is already registered.
- android 库 printf串口打印
- 连接远程数据库
- [转]DRBD管理控制台
- dos日期格式
- 如何在大多数文字编辑器中(包括word和一些程序编辑器中)不要使用鼠标(即用快捷键)复制上一行到下一行
- java动态代理
- 使用vimide建立自己的IDE
- [FromLOL]了解其他职业