Exemple #1
0
 /// <summary>
 /// 显示等待Panel
 /// </summary>
 /// <param name="ctrl"></param>
 /// <param name="getDataMethod"></param>
 /// <param name="getDataCompleteMethod"></param>
 /// <param name="waitingMsg"></param>
 public static void ShowWaitingPanel(this Control ctrl, TmoComm.LongTimeMethodDelegate getDataMethod, ParameterizedThreadStart getDataCompleteMethod,
                                     string waitingMsg = "数据加载中")
 {
     lock (_waitingPanelCache)
     {
         if (!_waitingPanelCache.ContainsKey(ctrl))
         {
             _waitingPanelCache[ctrl] = new WaitingPanel();
             ctrl.Disposed           += (sender, args) =>
             {
                 _waitingPanelCache[ctrl].Dispose();
                 _waitingPanelCache.Remove(ctrl);
             };
         }
         _waitingPanelCache[ctrl].Show(ctrl, getDataMethod, getDataCompleteMethod, waitingMsg);
     }
 }
        /// <summary>
        /// 显示等待Panel
        /// </summary>
        /// <param name="parentControl"></param>
        /// <param name="getDataMethod"></param>
        /// <param name="getDataCompleteMethod"></param>
        /// <param name="waitingMsg"></param>
        public void Show(Control parentControl, TmoComm.LongTimeMethodDelegate getDataMethod, ParameterizedThreadStart getDataCompleteMethod,
                         string waitingMsg = "数据加载中")
        {
            if (parentControl == null)
            {
                return;
            }
            Show(parentControl, waitingMsg);

            parentControl.CrossThreadCallsSync((object x) =>
            {
                if (getDataCompleteMethod != null)
                {
                    getDataCompleteMethod(x);
                }
                Hide(parentControl);
            }, getDataMethod);
        }