本文整理汇总了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));
}
示例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);
}
}
示例3: InvokeOwnThread
private void InvokeOwnThread(Control control, Action action)
{
if (control.InvokeRequired)
control.BeginInvoke(action);
else
action();
}
示例4: hider
private static void hider(Control frm)
{
frm.BeginInvoke((MethodInvoker)delegate
{
frm.Hide();
load.Hide();
});
}
示例5: BeginInvokeInControlThread
public static void BeginInvokeInControlThread(Control c, MethodInvoker code)
{
//c.BeginInvoke(code);
if (c.InvokeRequired)
c.BeginInvoke(code);
else
c.Invoke(code);
}
示例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);
}
示例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();
}
示例8: SafeInvokeAsync
public static void SafeInvokeAsync(Control ctr, Action action)
{
if (ctr == null || ctr.IsDisposed)
return;
if (ctr.InvokeRequired)
ctr.BeginInvoke(action);
else
action();
}
示例9: BeginInvokeIfControlCanHandleInvoke
public static bool BeginInvokeIfControlCanHandleInvoke(Control control, Delegate method)
{
if (ControlCanHandleInvoke(control))
{
control.BeginInvoke(method);
return true;
}
return false;
}
示例10: DoThreadSafe
public static void DoThreadSafe(Control control, MethodInvoker action)
{
if (control.InvokeRequired)
{
control.BeginInvoke(action);
}
else
{
action();
}
}
示例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();
}));
}
}
示例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);
}
示例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();
}
示例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;
}
}
示例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) {
}
}