/*
 * Backgroudn worker
 */
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace Project
{
    public partial class fMain
    {
        DateTime redisTryTime = DateTime.Parse("1982-11-23");
        Boolean bBW = true;
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            while (bBW)
            {
                //if (redisConnection == null)
                //{
                //    var ts = DateTime.Now - redisTryTime;
                //    if (ts.TotalMinutes > 5)
                //    {
                //        Console.WriteLine("redis conn : 10.131.36.57:6379");
                //        try
                //        {
                //            redisConnection = StackExchange.Redis.ConnectionMultiplexer.Connect("10.131.36.57:6379");
                //        }
                //        catch (Exception ex)
                //        {

                //        }
                //    }
                //}
                //else
                //{
                //    if (redisConnection.IsConnected)
                //    {
                //        if (this.db == null)
                //        {
                //            try
                //            {
                //                Console.WriteLine("redis connected setting db");
                //                this.db = redisConnection.GetDatabase();
                //                var getStr = this.db.StringGet("test");
                //                Console.WriteLine(getStr);
                //            }
                //            catch (Exception ex)
                //            {
                //                Pub.log.AddE("REDIS " + ex.Message);
                //            }

                //        }
                //    }
                //    else
                //    {
                //        Console.WriteLine("resetting redis connection");
                //        redisConnection.Dispose();
                //        redisConnection = null;
                //    }
                //}


                System.Threading.Thread.Sleep(5000);
            }
        }
    }
}
