在X秒后更改webview中的URL

时间:2015-04-20 22:44:27

标签: c# mysql awesomium

我有一个流量交换网站,现在我开始了一个C#项目,一个用于流量交换的自动化软件。 管理连接到MySQL服务器,检索数据,但我有一个大问题。

首先,这是代码:

 public Form1()
        {
            InitializeComponent();
            timer1 = new System.Windows.Forms.Timer();
            LoadUrls();
         }



public void LoadUrls()
        {
        try
            {
           string MyConnection2 = "******************";
           string Query = "select * from ******* where status = 1 AND credits > 5 ORDER BY rand() LIMIT 1";
            MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
            MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2);             
              MyConn2.Open();
            using (MySqlDataReader DR = MyCommand2.ExecuteReader())
            {
                while (DR.Read())
                {

                    string WebURL = Convert.ToString(DR.GetValue(*));
                    string WebSurfSeconds = Convert.ToString(DR.GetValue(*));

                    webControl1.Source = new Uri(WebURL);

                    int result = Convert.ToInt32(WebSurfSeconds);
                    int sec_to_mil = result * 1000;


                    timer1.Tick += new EventHandler(timer1_Tick);
                    timer1.Interval = sec_to_mil; // in miliseconds
                    timer1.Start();

                }
            }
            MyConn2.Close();
        }
catch (Exception ex)
        { 
            MessageBox.Show(ex.Message);
        }

     }


private void timer1_Tick(object sender, EventArgs e)
        {
            LoadUrls();
        }

代码执行流量交换应该做的事情,但仅限于有限的时间。

关于代码: 从数据库中取出一个随机网站,更改webview的网址(awesomium),然后在第二次重新运行timer1之后执行此命令。

前3-4个网站都很好,然后发疯。疯狂的我的意思是,即使计数器应该在60秒后重新运行命令,他会在2-3秒内完成。当这发生时,一切都消失了。没有回头路。

任何可能导致它的想法? 感谢。

0 个答案:

没有答案