private async void tryLoginAsync(int currentThtread, TopHopeAuth topHopeAuth) { bool isTryLogin; bool isLoginIn; isTryLogin = await topHopeAuth.Authorization(login[currentThtread - 1], password[currentThtread - 1]); if (isTryLogin) { isLoginIn = await topHopeAuth.checkerLogin(); if (isLoginIn) { lock (locker) { good++; labelsArray[(int)labels.Good].Content = good; testBox.Text += login[currentThtread - 1] + password[currentThtread - 1] + "Good" + "\n"; } await topHopeAuth.clientCreate(); } else { lock (locker) { bad++; labelsArray[(int)labels.Bad].Content = bad; testBox.Text += login[currentThtread - 1] + password[currentThtread - 1] + "Bad" + "\n"; } } } }
private void checkWork() { TopHopeAuth topHopeAuth = new TopHopeAuth(); topHopeAuth.clientCreate(); int currentThreadNum = 0; lock (locker) { threadNum++; currentThreadNum += threadNum; } Thread.Sleep(3000); if (accsNum >= currentThreadNum) { Application.Current.Dispatcher.BeginInvoke((new Action(() => { tryLoginAsync(currentThreadNum, topHopeAuth); }))); } else { Thread.CurrentThread.Abort(); } Thread.Sleep(3000); for (int i = 0; i < (accsNum / threadsCount) - 1; i++) { if (accsNum >= currentThreadNum) { currentThreadNum += threadsCount; Application.Current.Dispatcher.BeginInvoke((new Action(() => { tryLoginAsync(currentThreadNum, topHopeAuth); }))); } Thread.Sleep(100); } if (accsNum % threadsCount != 0 && currentThreadNum + threadsCount <= accsNum) { for (int i = accsNum - currentThreadNum; i <= accsNum - currentThreadNum; i++) { currentThreadNum += threadsCount; Application.Current.Dispatcher.BeginInvoke((new Action(() => { tryLoginAsync(currentThreadNum, topHopeAuth); }))); Thread.Sleep(100); } } Thread.CurrentThread.Abort(); }