Exemplo n.º 1
0
 /// <summary>
 /// 执行重连线程
 /// </summary>
 public void ExecuteReconnectThread()
 {
     while (isSave)
     {
         try
         {
             MarketTcpIp marketTcpIp = marketTcpIpBlockingCollection.Take();
             // if (!marketTcpIp.client.isConnected){
             if (!marketTcpIp.isOnReconnecting)
             {
                 Thread.Sleep(1000);
                 PrintToTxt("正在重连...");
                 marketTcpIp.ReConnect();
             }
         }
         catch (Exception ex)
         {
             marketErrorLoger.log(LogLevel.SYSTEMERROR, ex.ToString());
         }
     }
 }
Exemplo n.º 2
0
        public MainWindows()
        {
            InitializeComponent();
            marketBlockingCollection      = new BlockingCollection <MarketInfo>();
            marketTcpIpBlockingCollection = new BlockingCollection <MarketTcpIp>();
            string serverIP   = ConfigurationManager.AppSettings["MarketIp"];
            string serverPort = ConfigurationManager.AppSettings["MarketPort"];

            marketType       = ConfigurationManager.AppSettings["MarketType"];
            this.Text        = this.Text + "_" + marketType;
            marketErrorLoger = new WriteLog("./log/marketError.log", LogLevel.ALL);
            //获取Redis操作接口
            Redis = RedisManager.GetClient();
            //放在1号数据库
            //Redis.Db = 1;
            marketTcpClient            = new MarketTcpIp(serverIP, int.Parse(serverPort));
            marketTcpClient.mainWindow = this;
            marketTcpClient.setVersion(100);
            marketTcpClient.setSize(1024 * 1024 * 4);
            //marketTcpClient.isWriteLog = true;
            marketTcpClient.Connect();
            isSave = true;
        }