示例#1
0
        /// <summary>
        /// 释放线程,及关闭ZmqContext, ZmqSocket等
        /// </summary>
        public static void Dispose()
        {
            object[] objs = _componentDict.Values.ToArray <object>();

            for (int i = objs.Length - 1; i >= 0; i--)
            {
                IDisposable socket = objs[i] as IDisposable;
                socket.Dispose();
            }

            Thread.Sleep(200);
            if (_worker != null)
            {
                _worker.Dispose();
                _worker = null;
            }
        }
示例#2
0
        public static RockWorker CreateRockWorker(ushort router, uint node, string remoteAddress)
        {
            _localVIP = new VirtuaIP()
            {
                Router = router,
                Node   = node,
            };

            //加载通信所需DynClass
            DynClassLoader.LoadDynClass();

            if (_worker != null)
            {
                throw new ApplicationException("RockWorker已经创建完成,不需要再次创建");
            }
            _worker = new RockWorker(_localVIP, remoteAddress);
            _worker.Start();
            return(_worker);
        }