c# - Query inside a thread -
i have 3 comboboxes loaded data linq queries on page load. problem queries contain data causes internet explorer stop responding bit more minute.
as there 3 queries idea put them in 3 different threads, problem @ end thing error saying: "both datasource , datasourceid defined on 'cborganizator'. remove 1 definition."
cborganizator combobox.
here code:
protected void page_load(object sender, eventargs e) { bind(); } public void osobe() { pravosudnaakademijaentities db = new pravosudnaakademijaentities(); var osoba = o in db.osobas orderby o.osoba_prezime select new { o.osoba_id, imeprezime = o.osoba_prezime + " " + o.osoba_ime + " | " + o.tijelo.tijelo_naziv + " | " + o.radno_mjesto.rm_naziv_m }; cbpolaznik.datasource = osoba; cbpolaznik.datatextfield = "imeprezime"; cbpolaznik.datavaluefield = "osoba_id"; cbpolaznik.databind(); cbpolaznik.items.insert(0, " "); cbpredavac.datasource = osoba; cbpredavac.datatextfield = "imeprezime"; cbpredavac.datavaluefield = "osoba_id"; cbpredavac.databind(); cbpredavac.items.insert(0, " "); cbaom.datasource = osoba; cbaom.datatextfield = "imeprezime"; cbaom.datavaluefield = "osoba_id"; cbaom.databind(); cbaom.items.insert(0, " "); } public void tijela() { pravosudnaakademijaentities db = new pravosudnaakademijaentities(); var tijelo = t in db.tijeloes orderby t.tijelo_naziv select new { t.tijelo_id, sve = t.tijelo_naziv + " | " + t.mjesto.zupanija_drzava.zupanija_naziv }; cborganizator.datasource = tijelo; cborganizator.datatextfield = "sve"; cborganizator.datavaluefield = "tijelo_id"; cborganizator.databind(); cborganizator.items.insert(0, " "); } public void bind() { thread tosobe = new thread(osobe); tosobe.start(); thread ttijela = new thread(tijela); ttijela.start(); }
i don't know what's wrong appreciated. primary idea separate queries threads if approach wrong please let me know.
you're starting threads not giving them chance finish before page loaded. don't know how results in particular error, if page loads before thread completed, won't results.
i don't see how you'll able accomplish you're trying without ajax.
Comments
Post a Comment