本文整理汇总了C#中System.Windows.Forms.TextBox.InvokeIfRequired方法的典型用法代码示例。如果您正苦于以下问题:C# TextBox.InvokeIfRequired方法的具体用法?C# TextBox.InvokeIfRequired怎么用?C# TextBox.InvokeIfRequired使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TextBox
的用法示例。
在下文中一共展示了TextBox.InvokeIfRequired方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BackgroundExecutorWithStatus
public BackgroundExecutorWithStatus(TextBox control, string textToAnimate)
{
_statusControl = control;
AnimateText = string.Empty;
_maxDots = 4;
AnimateText = textToAnimate;
_statusControl.TextChanged += (sender, e) =>
{
_statusControl.InvokeIfRequired(tb =>
{
tb.Focus();
tb.SelectionStart = tb.Text.Length;
tb.ScrollToCaret();
});
};
Log.WriteVerbose(new SourceInfo(), "Initializing Background Worker.");
_actionWorker = new BackgroundExecutorBase();
_actionWorker.DoWork += actionWorker_DoWork;
_actionWorker.ProgressChanged += actionWorker_ProgressChanged;
_actionWorker.RunWorkerCompleted += actionWorker_RunWorkerCompleted;
}
示例2: UpdateUiTextbox
private static void UpdateUiTextbox(BackgroundExecutorWithStatus bgws, TextBox textbox, string msg, params object[] args)
{
if (args.Length != 0)
{
msg = string.Format(msg, args);
}
if (bgws != null)
{
bgws.AnimateText = msg;
}
else
{
textbox.InvokeIfRequired(s =>
{
s.Text += Environment.NewLine + msg;
});
}
}