日期:2014-05-17  浏览次数:20959 次

异步加载还是出问题?

//先是定义
   public delegate void  DelegateLoadName1(string tblName ,ComboBox cmb);
....
//接着再加载过程定义
   DelegateLoadName1 qudao = new DelegateLoadName1(AsyLoadName1);
  AsyncCallback Aysqudao = new AsyncCallback(this.AsyncCallbackValue);
  qudao.BeginInvoke("tbqudao", cmbCzFs, Aysqudao, "渠道加载");
.....

//定义了委托方式
 #region 异步加载数据库快捷信息
        private  void AsyncCallbackValue(IAsyncResult ar)
        {
            Console.WriteLine("" + ar.AsyncState +"加载结束");
        }

        private void AsyLoadName1(string tblname, ComboBox cmb)
        {
            CBaseFunc.LoadName(tblname , cmb );
        }
        private void AsyLoadName2(string tblname, ComboBox cmb,int tmp)
        {
            CBaseFunc.LoadName(tblname , cmb , tmp);
        }

        #endregion

//
 /// <summary>
        /// 加载基本表的名称
        /// </summary>
        /// <param name="tblName"></param>
        /// <param name="cmb"></param>
         public static  void LoadName(string tblName, ComboBox cmb)
        {
            TianLi.BLL.tbBaseInfo fBl= new TianLi.BLL.tbBaseInfo(tblName);

            cmb.SuspendLayout();
            cmb.Items.Clear(); ///**********提示线程冲突
            cmb.BeginUpdate();
        
            try
            {
                if (fBl.GetAllName() == null)
                { cmb.EndUpdate(); }
                else
                {
                    cmb.Items.AddRange(fBl.GetAllName().ToArray());
                    cmb.EndUpdate();
     &nbs