示例#1
0
        private static void OpenAdomdClientConnection(object o)
        {
            ConnectAdomdClientInfo info = null;

            try
            {
                info = (ConnectAdomdClientInfo)o;
                Microsoft.AnalysisServices.AdomdClient.AdomdConnection s = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection(info.ConnectionString);
                s.Open();
                info.Server = s;
            }
            catch (Exception ex)
            {
                info.ex = ex;
            }
            finally
            {
                info.autoEvent.Set();
            }
        }
示例#2
0
        /// <summary>
        /// Returns an open connection with AdomdClient
        /// Connection is opened on a background thread
        /// Helps ensure a sproc trying to open an AdomdClient connection does not get deadlocked
        /// </summary>
        /// <param name="ConnectionString"></param>
        /// <returns></returns>
        public static Microsoft.AnalysisServices.AdomdClient.AdomdConnection ConnectAdomdClient(string ConnectionString)
        {
            ConnectAdomdClientInfo info = new ConnectAdomdClientInfo();

            info.ConnectionString = ConnectionString;
            info.autoEvent        = new System.Threading.AutoResetEvent(false);
            System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(OpenAdomdClientConnection), 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;
            }
            else
            {
                return(info.Server);
            }
        }