0

Look at this code:

foreach (string t in tar) {
    for (int i = 0; i < Program.CountAccount; i++) {
        Program.log("Лайк " + t);
        int ind = i;
        ts[ind] = new Task(delegate {
        MessageBox.Show(
            //cooks[Index]
            Program.browsers[ind].CookieContainer.GetCookies(new Uri("http://m.ok.ru/")).Count.ToString(), "count");
        Program.browsers[ind].Liking(t);
    }); ts[ind].Start();

The cookie is empty, if I not use int IND.

Why i need to use IND? Without it logic breaks (cookie in my browser is empty in new thread), I met this bug a lot of times, solution is to use an additional variable, but can you tell me, what I'm doing wrong, why for(i[0-N]) can't access static object MyClient browsers[i]?

Softlion
  • 12,281
  • 11
  • 58
  • 88

0 Answers0