private static void FillAdomdDataAdapterWorker(object o) { FillAdomdDataAdapterInfo info = null; try { info = (FillAdomdDataAdapterInfo)o; info.adapter.Fill(info.table); } catch (Exception ex) { info.ex = ex; } finally { info.autoEvent.Set(); } }
/// <summary> /// Fills a DataTable using the specified AdomdDataAdapter /// This is done on a background thread /// Helps ensure a sproc trying to fill a DataTable does not get deadlocked /// </summary> /// <param name="adp"></param> /// <param name="tbl"></param> public static void FillAdomdDataAdapter(Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter adp, System.Data.DataTable tbl) { FillAdomdDataAdapterInfo info = new FillAdomdDataAdapterInfo(); info.adapter = adp; info.table = tbl; info.autoEvent = new System.Threading.AutoResetEvent(false); System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(FillAdomdDataAdapterWorker), info); while (!info.autoEvent.WaitOne(1000, false)) { Context.CheckCancelled(); //if the parent query has been cancelled (or the ForceCommitTimeout expires) then this will immediately exit } if (info.ex != null) { throw info.ex; } }