private void PerformQuery(object sender, DoWorkEventArgs e) { DownloaderResult dr = new DownloaderResult(); DownloaderArguments da = e.Argument as DownloaderArguments; try { dr.Result = new QueryResult(DataRetriever.RetrieveData(da.DataProvider, da.StartDate, da.EndDate, da.Company), da.Company); } catch(CompanyNotFoundException) { dr.ControlCausedError = tbCompanyName; dr.Error = "Company not found in records."; } catch(ConnectionErrorException) { dr.Error = "Network error, cannot contact data source."; } catch(DataProviderNotValidException) { dr.Error = "Data provider doesn't exist."; } e.Result = dr; }
private void PerformQuery(object sender, DoWorkEventArgs e) { DownloaderResult[] dr = new DownloaderResult[2]; DownloaderArguments[] da = e.Argument as DownloaderArguments[]; int i; for (i = 0; i < 2; i++) { dr[i] = new DownloaderResult(); try { dr[i].Result = new QueryResult(DataRetriever.RetrieveData(da[i].DataProvider, da[i].StartDate, da[i].EndDate, da[i].Company), da[i].Company); } catch (CompanyNotFoundException) { if (i == 0) dr[i].ControlCausedError = tbCompanyName; else dr[i].ControlCausedError = textBox1; dr[i].Error = "Company not found in records."; } catch (ConnectionErrorException) { dr[i].Error = "Network error, cannot contact data source."; } catch (DataProviderNotValidException) { dr[i].Error = "Data provider doesn't exist."; } } e.Result = dr; }