当前位置: 首页>>代码示例>>C#>>正文


C# Control.BeginInvoke方法代码示例

本文整理汇总了C#中System.Windows.Forms.Control.BeginInvoke方法的典型用法代码示例。如果您正苦于以下问题:C# Control.BeginInvoke方法的具体用法?C# Control.BeginInvoke怎么用?C# Control.BeginInvoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.Control的用法示例。


在下文中一共展示了Control.BeginInvoke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PerformControlOperation

 /// <summary>
 /// Performs the action on the control by calling BeginInvoke, if it is required to do so
 /// </summary>
 /// <param name="control"></param>
 /// <param name="action"></param>
 public static void PerformControlOperation(Control control, NoParam action)
 {
     if (control.InvokeRequired)
         control.BeginInvoke(new InvokeDelegate(TryCatchInvoker), new Invoke(action, null));
     else
         TryCatchInvoker(new Invoke(action, null));
 }
开发者ID:claudiuslollarius,项目名称:monotorrent,代码行数:12,代码来源:Utils.cs

示例2: Invoke

 /// <summary>
 /// 跨线程访问控件
 /// </summary>
 /// <param name="ctrl">Form对象</param>
 /// <param name="de">委托</param>
 public static void Invoke(Control ctrl, Delegate de)
 {
     if (ctrl.IsHandleCreated)
     {
         ctrl.BeginInvoke(de);
     }
 }
开发者ID:0611163,项目名称:Machine,代码行数:12,代码来源:InvokeUtil.cs

示例3: InvokeOwnThread

 private void InvokeOwnThread(Control control, Action action)
 {
     if (control.InvokeRequired)
         control.BeginInvoke(action);
     else
         action();
 }
开发者ID:SyncZone,项目名称:WinFormHelper,代码行数:7,代码来源:MainLoop.cs

示例4: hider

 private static void hider(Control frm)
 {
     frm.BeginInvoke((MethodInvoker)delegate
     {
         frm.Hide();
         load.Hide();
     });
 }
开发者ID:ainma007,项目名称:UcasProject,代码行数:8,代码来源:Operation.cs

示例5: BeginInvokeInControlThread

 public static void BeginInvokeInControlThread(Control c, MethodInvoker code)
 {
     //c.BeginInvoke(code);
     if (c.InvokeRequired)
         c.BeginInvoke(code);
     else
         c.Invoke(code);
 }
开发者ID:sergeystoyan,项目名称:FhrCliverHost,代码行数:8,代码来源:BaseForm.cs

示例6: BeginInvoke

        /// <summary>
        /// Invokes asynchronously the specified action for this control.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="action">The action.</param>
        public static void BeginInvoke(Control control, Action action)
        {
            control.ThrowIfNull("control");
            action.ThrowIfNull("action");
            if (!control.Created || control.IsDisposed || !control.IsHandleCreated) return;

            control.BeginInvoke(action);
        }
开发者ID:liquidsnk,项目名称:Aspid,代码行数:13,代码来源:ControlUtils.cs

示例7: effectSmoothChangeWidth

 /// <summary>
 /// Simply changes the Width property with smoothing, for any controls
 /// </summary>
 /// <param name="control"></param>
 /// <param name="max">max Width</param>
 /// <param name="distance">Steps in the range (0-1)</param>
 /// <param name="delay">in milliseconds</param>
 public static void effectSmoothChangeWidth(Control control, int max, float distance, int delay)
 {
     distance = Math.Max(0, Math.Min(distance, 1));
     (new System.Threading.Tasks.Task(() =>
     {
         int step = (int)(max * distance);
         while(control.Width < max)
         {
             control.BeginInvoke((MethodInvoker)delegate {
                 control.Width += step;
             });
             System.Threading.Thread.Sleep(delay);
         }
         control.BeginInvoke((MethodInvoker)delegate {
             control.Width = max;
         });
     })).Start();
 }
开发者ID:modulexcite,项目名称:vsCommandEvent,代码行数:25,代码来源:Util.cs

示例8: SafeInvokeAsync

        public static void SafeInvokeAsync(Control ctr, Action action)
        {
            if (ctr == null || ctr.IsDisposed)
                return;

            if (ctr.InvokeRequired)
                ctr.BeginInvoke(action);
            else
                action();
        }
开发者ID:nutrija,项目名称:TemplaterExamples,代码行数:10,代码来源:Threading.cs

示例9: BeginInvokeIfControlCanHandleInvoke

        public static bool BeginInvokeIfControlCanHandleInvoke(Control control, Delegate method)
        {
            if (ControlCanHandleInvoke(control))
            {
                control.BeginInvoke(method);
                return true;
            }

            return false;
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:10,代码来源:ControlHelper.cs

示例10: DoThreadSafe

 public static void DoThreadSafe(Control control, MethodInvoker action)
 {
     if (control.InvokeRequired)
     {
         control.BeginInvoke(action);
     }
     else
     {
         action();
     }
 }
开发者ID:Necrophagos,项目名称:SF4ComboTrainer,代码行数:11,代码来源:Form1.cs

示例11: AfterAllClear

 public static void AfterAllClear(Control rate, Control pokemonNames)
 {
     if (Settings.Default.NoInputRate) {
         pokemonNames.BeginInvoke((MethodInvoker)(() => {
             pokemonNames.Select();
         }));
     } else {
         rate.BeginInvoke((MethodInvoker)(() => {
             rate.Select();
         }));
     }
 }
开发者ID:ouaiea,项目名称:miseruge1,代码行数:12,代码来源:SettingsController.cs

示例12: ExecuteOnUIThread

 /// <summary>
 /// Attempts to run a delegate method on the UI thread of a System.Windows.Forms.Control
 /// Basically a wrapper around BeginInvoke with testing for readiness / availability of the
 /// control itself
 /// </summary>
 /// <param name="control">Control to run on</param>
 /// <param name="method">delegate method to run</param>
 public static void ExecuteOnUIThread(Control control, Delegate method)
 {
     for (var i = 0; i < 30; i++)
     {
         if (control.IsHandleCreated)
             break;
         if (control.IsDisposed || control.Disposing)
             return;
         Thread.Sleep(100);
     }
     control.BeginInvoke(method);
 }
开发者ID:Chillisoft,项目名称:habanero.faces,代码行数:19,代码来源:UIThreadExecutorWin.cs

示例13: RefreshControl

 //***************************************************************************
 // Static Methods
 // 
 /// <summary>
 /// Tells the specified control to invalidate its client area and immediately redraw itself.
 /// </summary>
 /// <param name="ctrl"></param>
 public static void RefreshControl(Control ctrl)
 {
     if (ctrl.InvokeRequired)
     {
         RefreshControlDelegate del = new RefreshControlDelegate(CrossThreadUI.RefreshControl);
         if (CrossThreadUI.ExecSync)
             ctrl.Invoke(del);
         else
             ctrl.BeginInvoke(del);
     }
     else
         ctrl.Invalidate();
 }
开发者ID:tenshino,项目名称:RainstormStudios,代码行数:20,代码来源:CrossThreadUI.cs

示例14: ActivateControl

 // activate / deactivate control
 public static void ActivateControl(Control aControl, bool aActive)
 {
     if (aControl.InvokeRequired)
     {
         aControl.BeginInvoke(
             new MethodInvoker(delegate() { ActivateControl(aControl, aActive); })
         );
     }
     else
     {
         aControl.Enabled = aActive;
     }
 }
开发者ID:plamikcho,项目名称:easyresx,代码行数:14,代码来源:FormCommonUtils.cs

示例15: BeginInvoke

 //http://rsdn.ru/forum/dotnet/2285015.aspx
 /// <summary>
 /// private void SetIntSignalLevel(int SigValue)
 /// {
 /// 	SafeInvoker.Invoke(SigLevel,
 /// 		delegate
 ///			{
 /// 				SigLevel.Value = SigValue;
 /// 		}
 ///		);
 /// }
 /// </summary>
 /// <param name="ctrl"></param>
 /// <param name="methodToInvoke"> delegate { ProgressBar.Value = value; } </param>
 public static void BeginInvoke(Control ctrl, MethodInvoker methodToInvoke)
 {
     try {
         if (ctrl == null || ctrl.IsDisposed)
             return;
         if (ctrl.InvokeRequired) {
             ctrl.BeginInvoke (methodToInvoke);
         } else {
             methodToInvoke ();
         }
     } catch (ObjectDisposedException) {
     }
 }
开发者ID:vc,项目名称:from-editor,代码行数:27,代码来源:HelperClass.cs


注:本文中的System.Windows.Forms.Control.BeginInvoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。