private void backgroundWorkerDataService_DoWork(object sender, DoWorkEventArgs e) { try { if ((e.Argument as Dictionary<string, string>).Count != 0) { var db = new DAO.Database(e.Argument as Dictionary<string, string>); e.Result = db.GetImage(DAO.IMAGE_TYPE.wsq, _id); } else { var db = new DBHelper.DBUtil(); e.Result = db.GetImageFromWebService(IMAGE_TYPE.wsq, _id); } } catch (Exception ex) { throw new Exception(ex.Message); } }