嵌套计时器代码不起作用

nested timer code is not working

我制作了一个流量机器人...它适用于一个网站。我将它设置到多个网站。 因此我编码如下。

 IEnumerator<string> proxies;
    IEnumerator<string> websites;
    private void button1_Click(object sender, EventArgs e)
    {
        List<string> strings = new List<string>();

        string[] ipaddress = textBox2.Text.Split('\n');

        for(int i=0;i<Convert.ToInt32(ipaddress.Length);i++){

            strings.Add(ipaddress[i]);
        }


        proxies = strings.GetEnumerator();
        timer1.Start();

        //websites = strings.GetEnumerator();
        //timer1.Start();
      //  websites.MoveNext();
        proxies.MoveNext();
    }


    private void timer1_Tick(object sender, EventArgs e)
    {


        WinInetInterop.SetConnectionProxy(proxies.Current);
        label1.Text = proxies.Current;
        string[] website = textBox1.Text.Split('\n');
        List<string> stringsweb = new List<string>();

        for (int j = 0; j < Convert.ToInt32(website.Length); j++)
        {

            stringsweb.Add(website[j]);
        }

        websites = stringsweb.GetEnumerator();
        timer2.Enabled = true;


            //webBrowser1.Navigate(website[0]);

        timer1.Enabled = proxies.MoveNext();



    }

   private void timer2_Tick(object sender, EventArgs e)
    {
        webBrowser1.Navigate(websites.Current);
        label2.Text = websites.Current;
        timer2.Enabled = websites.MoveNext();
    }

如您所见,我在 timer1_Tick 中调用了一个 timer2_Tick 方法...但是我的代码不起作用...

问题是它没有调用 timer1_tick 中的 timer2_Tick 方法,所以网站没有加载...

Timer1,Timer2间隔=10s

我想做

从 textbox2 获取一个代理 ---> 为该代理加载 2 个网站

请告诉我我的错误

我无法测试,但我想你的计时器相互重叠,所以你可以尝试更好地同步它们的滴答声

IEnumerator<string> proxies;
IEnumerator<string> websites;
private void button1_Click(object sender, EventArgs e)
{
    List<string> strings = new List<string>();
    strings = textBox2.Text.Split('\n').ToList();
    proxies = strings.GetEnumerator();
    timer1.Start();
}

private void timer1_Tick(object sender, EventArgs e)
{
    // Stop the first timer until the second one completes
    timer1.Enabled = false;
    WinInetInterop.SetConnectionProxy(proxies.Current);
    label1.Text = proxies.Current;
    List<string> stringsweb = textBox1.Text.Split('\n').ToList();
    websites = stringsweb.GetEnumerator();
    timer2.Enabled = true;
}

private void timer2_Tick(object sender, EventArgs e)
{
    webBrowser1.Navigate(websites.Current);
    label2.Text = websites.Current;

    // Let's continue with the second timer until completition
    timer2.Enabled = websites.MoveNext();

    // Reenable the first when the second timer completes
    if(!timer2.Enabled) 
        timer1.Enabled = strings.MoveNext();
}