Exemplo n.º 1
0
        void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            System.Timers.Timer t = (System.Timers.Timer)sender;
            t.Enabled = false;
            IDictionaryEnumerator enumerator = this.Sokcets.GetEnumerator();

            Config.SocketCItem item = null;
            while (enumerator.MoveNext())
            {
                Bp.Socket.Client socket = enumerator.Value as Bp.Socket.Client;
                item = (Config.SocketCItem)socket.DeviceType;
                if (item.Timer == t)
                {
                    if (!item.IsConnected)
                    {
                        socket.DoStart();
                    }
                    break;
                }
            }
            if (!item.IsConnected)
            {
                t.Enabled = true;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 启动
        /// </summary>
        public override void DoStart()
        {
            try
            {
                IDictionaryEnumerator enumerator = this.Sokcets.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    Bp.Socket.Client socket = enumerator.Value as Bp.Socket.Client;
                    socket.DoStart();

                    if (!socket.IsConnected)
                    {
                        Config.SocketCItem item = (Config.SocketCItem)socket.DeviceType;
                        item.Timer.Enabled = true;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new StartException(this.ToString(), ex.ToString());
            }
        }