//Prepare the threads to check prime numbers public void set_threads() { string log = ""; txtLog.Text = ""; int starting = 2; int counter = 0; baslangic: log += "Thread " + counter.ToString() + " => Starting : " + Convert.ToInt32(starting).ToString() + " ; Ending : " + (starting + Convert.ToInt32(lblThreadCheckBetween.Text)).ToString() + Environment.NewLine; using (linqDataContext linq = new linqDataContext()) { temp tmp = new temp(); { tmp.th = counter; tmp.bas = starting; tmp.son = starting + Convert.ToInt32(lblThreadCheckBetween.Text); } linq.temps.InsertOnSubmit(tmp); linq.SubmitChanges(); } starting += Convert.ToInt32(lblThreadCheckBetween.Text); counter++; if (counter < Convert.ToInt32(lblThreadsNeed.Text)) { goto baslangic; } if (starting < int.Parse(lblMaxValue.Text)) { log += "Thread " + counter.ToString() + " => Starting : " + Convert.ToInt32(starting).ToString() + " ; Ending : " + (Convert.ToInt32(lblMaxValue.Text)).ToString() + Environment.NewLine; using (linqDataContext linq = new linqDataContext()) { temp tmp = new temp(); { tmp.th = counter; tmp.bas = starting; tmp.son = starting + Convert.ToInt32(lblThreadCheckBetween.Text); } linq.temps.InsertOnSubmit(tmp); linq.SubmitChanges(); } } txtLog.Text = log; }
//main function of the program public bool main_function() { if (contunie) { using (linqDataContext linq = new linqDataContext()) { var sorgu = (from p in linq.temps select p); foreach (var item in sorgu) { Thread th = new Thread(() => control_prime_numbers(Convert.ToInt32(item.bas), Convert.ToInt32(item.son))); th.Start(); } temp tmp = new temp(); linq.ExecuteCommand("delete from temp"); } return(true); } else { backgroundWorker1.CancelAsync(); return(false); } }
partial void Updatetemp(temp instance);
partial void Deletetemp(temp instance);
partial void Inserttemp(temp instance);