c# - runs false if statement when creating new threads -
I am writing a program that will email the facts of the cat on a mailing list (not spamming, it is more than anyone Also the experience of learning from the thing) I have 2 arrays, 1 facts (no problem) and an email always throws an exception for an email (even in an attempt / catch block) and all my statements are completely Are ignored when it moves.
Public Zero Broadcasting () {Fact ++; If (fact == factCount) {fact = 0; } String [] Mailer = mailing list. ToArray (); String [] factArray = factList.ToArray (); Int i = Mailer Lang -1; Send string fact = factarre [facts]; While (i> = 0) {string s = melare [i]; Var t = new thread (() => mail (mailer [i], sendFact)); TIsbackground = true; T.Start (); I--; If (i == - 1) {break; }}
The problem is here:
var t = new thread ((=) => mail (mailer [i], sendFact));
Even when 'I' is 1, the statement continues and the break is ignored. Originally, I participated in the reverse 'i', starting with 0 and crossing Melaira. EDIT:
EDIT:
EDIT:
I moved :
var t = new thread ((=) => mail (mailer [i], sendFact)); TIsbackground = true; T.Start ();
For a new method, it is said that instead of the above code -. That works perfectly well
You are creating a stop on the loop variable - Using this one
directly as the current value, you have already assigned to do this, it will fix it:
while (i> = 0) {string s = mailArray [i]; Var t = new thread ((=); mail (s, transmitted)); // ..}
Comments
Post a Comment