private void BtnGetDataSet_OnClick(object sender, RoutedEventArgs e) { string strConn = string.Format("Data Source={0},{1};Initial Catalog={2};User Id={3};Password={4}" , "192.168.4.181", 1433, "UMPDataDB0319", "VCLogIMP", "imp_123"); string strSql = string.Format("select top 200 * from T_21_000"); SubDebug(string.Format("Getting data...")); mWorker = new BackgroundWorker(); mWorker.DoWork += (s, de) => { OperationReturn optReturn = DBAccessHelper.GetDataSet(strConn, strSql); if (!optReturn.Result) { SubDebug(string.Format("Fail.\t{0}", optReturn)); } else { DataSet objDS = optReturn.Data as DataSet; if (objDS == null) { SubDebug(string.Format("DataSet is null")); } else { SubDebug(string.Format("End.\t{0}", objDS.Tables[0].Rows.Count)); } } }; mWorker.RunWorkerCompleted += (s, re) => { mWorker.Dispose(); mWorker = null; }; mWorker.RunWorkerAsync(); }