By Ki u Beograd


2019-09-11 09:19:14 8 Comments

I have no idea why but my Task is executing a code only 2 times when i made 5 tasks to execute it.

for (int i = 0; i< 5; i++)
//MainUI
{
    Task.Run(() =>
    {
        string s = Settings.ComboList[rnd.Next(Settings.ComboList.Count)];
        string[] split = s.Split(":".ToCharArray());
        string username = split[0];
        string password = split[1];
        twitch.GetOAuth(username, password, nesto, noCaptcha, proxyless, string.Empty);
        Settings.ComboList.Remove(s);
    });
}

public void GetOAuth(string Username, string Password, string Captchakey, bool noCaptcha, bool proxy, string proxyString)
//mainVoid
{
    Console.WriteLine(noCaptcha);
    var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://passport.twitch.tv/login");
    httpWebRequest.ContentType = "application/json";
    httpWebRequest.Method = "POST";
    if (proxy == false)
    {
        string[] split = proxyString.Split(":".ToCharArray());
        string proxyNum = split[0];
        int port = int.Parse(split[1]);
        httpWebRequest.Proxy = new WebProxy(proxyNum, port);
    }
    else
    {

    }
    Console.WriteLine("Pred Captchu");
    using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
    {
        if (noCaptcha == false)
        {
            Console.WriteLine("Captcha Solviong...");
            CaptchaSolver client = new CaptchaSolver(Captchakey);
            client.SolveRecaptchaV2("6Ld65QcTAAAAAMBbAE8dkJq4Wi4CsJy7flvKhYqX", "https://passport.twitch.tv/login", string.Empty, ProxyType.HTTP, out string captchaResult);

            string json = "{\"username\":\"" + Username + "\",\"password\":\"" + Password + "\",\"client_id\":\"kimne78kx3ncx6brgo4mv6wki5h1ko\",\"undelete_user\":false,\"captcha\":{\"value\":\"" + captchaResult + "\",\"key\":\"6Ld65QcTAAAAAMBbAE8dkJq4Wi4CsJy7flvKhYqX\"}}";

            streamWriter.Write(json);
        }
        else
        {
            string json = "{\"username\":\"" + Username + "\",\"password\":\"" + Password + "\",\"client_id\":\"kimne78kx3ncx6brgo4mv6wki5h1ko\",\"undelete_user\":false}";

            streamWriter.Write(json);
        }
    }
    Console.WriteLine("Finished");
    var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
    using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
    {
        var result = streamReader.ReadToEnd();
        string Code = TextParser.getBetween(result, "{\"access_token\":\"", "\"");
        Console.WriteLine(Code);

        bool getPrime = GetPrime(Code);
        GetDetails(Code, getPrime, Username, Password);

    }
}

Results I'm getting:

False
False
False
False
False
Pred Captchu
Pred Captchu
Pred Captchu
Pred Captchu
Pred Captchu
Captcha Solviong...
Captcha Solviong...

After it finished first 2 than it runs other 2 than the last one Edit 1. I checked again and all 5 task execute until this line where only 2 task execute.Every Task executes the line untill this one:

using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))

0 comments

Related Questions

Sponsored Content

14 Answered Questions

[SOLVED] Collection was modified; enumeration operation may not execute

15 Answered Questions

[SOLVED] Embedding DLLs in a compiled executable

7 Answered Questions

[SOLVED] What is the difference between task and thread?

25 Answered Questions

[SOLVED] How should I unit test threaded code?

37 Answered Questions

[SOLVED] Calculate relative time in C#

6 Answered Questions

[SOLVED] Calculate the execution time of a method

27 Answered Questions

[SOLVED] How do I get the path of the assembly the code is in?

  • 2008-09-09 20:12:28
  • George Mauer
  • 570992 View
  • 732 Score
  • 27 Answer
  • Tags:   c# .net reflection

5 Answered Questions

[SOLVED] Try-catch speeding up my code?

4 Answered Questions

[SOLVED] Task continuation on UI thread

Sponsored Content