private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { try { using (DBWokrSql db = new DBWokrSql(Connection)) { var levels_ = (Dictionary <int, string>)db.GetLevels(); var topics_ = (Dictionary <int, string>)db.GetTopics(); var qq = new Dictionary <QuestionInfo, IEnumerable <AnswerInfo> >(); foreach (var item in db.GetIDQuestions(0, 0)) { var question_ = db.GetQuestion(item); var answers_ = db.GetAnswers(item); qq.Add(question_, answers_); } e.Cancel = false; e.Result = new { lev = levels_, topi = topics_, q = qq }; } } catch (Exception ex) { e.Cancel = false; e.Result = "Не має зв`язку з базою: " + ex.Message; } }