private void MainWork_DoWork(object sender, DoWorkEventArgs e) { StockQuery query = new StockQuery(); List<Task> taskList = new List<Task>(); // 檢查是否為交易日 // Step 1. Query Basic Data taskList.Add(new Task(() => { query.QueryBroker(); })); taskList.Add(new Task(() => { query.QueryBrokerBranch(); })); taskList.Add(new Task(() => { query.QueryCompany(); })); foreach (var item in taskList) { item.Start(); } Task.WaitAll(taskList.ToArray()); taskList.Clear(); // Step 2. Query Stock Summary taskList.Add(new Task(() => { query.QueryDaliyWork(); })); foreach (var item in taskList) { item.Start(); } Task.WaitAll(taskList.ToArray()); // Check Progress // Daily Settlement // Daily Rate // Weekly Rate }
static void dailyInit() { StockQuery query = new StockQuery(); List<Task> taskList = new List<Task>(); taskList.Add(new Task(() => { query.QueryBroker(); })); taskList.Add(new Task(() => { query.QueryBrokerBranch(); })); taskList.Add(new Task(() => { query.QueryCompany(); })); foreach (var item in taskList) { item.Start(); } Task.WaitAll(taskList.ToArray()); taskList.Clear(); taskList.Add(new Task(() => { query.QueryDaliyWork(); })); foreach (var item in taskList) { item.Start(); } Task.WaitAll(taskList.ToArray()); }
private void InitWorker_DoWork(object sender, DoWorkEventArgs e) { StockQuery query = new StockQuery(); switch ((int)e.Argument) { case 0: InitWorker.ReportProgress(0, "BasicData Start"); query.QueryBroker(); query.QueryBrokerBranch(); query.QueryCompany(); // query.QueryDaliyWork(); query.QueryStockWarrant(); InitWorker.ReportProgress(0, "BasicData Done"); break; case 1: InitWorker.ReportProgress(0, "StockData Start"); query.QueryDaliyWork(); query.QueryStockWarrant(); InitWorker.ReportProgress(0, "StockData Done"); break; default: break; } }