本文整理汇总了C#中Form.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# Form.Invoke方法的具体用法?C# Form.Invoke怎么用?C# Form.Invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Form
的用法示例。
在下文中一共展示了Form.Invoke方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnregisterHotKey
public static void UnregisterHotKey(Form f)
{
try
{
Func ff = delegate()
{
UnregisterHotKey(f.Handle, keyId); // modify this if you want more than one hotkey
};
f.Invoke(ff); // this should be checked if we really need it (InvokeRequired), but it's faster this way
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
}
示例2: RegisterHotKey
public static void RegisterHotKey(Form f, Keys key)
{
int modifiers = 0;
if ((key & Keys.Alt) == Keys.Alt)
modifiers = modifiers | WindowsShell.MOD_ALT;
if ((key & Keys.Control) == Keys.Control)
modifiers = modifiers | WindowsShell.MOD_CONTROL;
if ((key & Keys.Shift) == Keys.Shift)
modifiers = modifiers | WindowsShell.MOD_SHIFT;
Keys k = key & ~Keys.Control & ~Keys.Shift & ~Keys.Alt;
Func ff = delegate()
{
keyId = f.GetHashCode(); // this should be a key unique ID, modify this if you want more than one hotkey
RegisterHotKey((IntPtr)f.Handle, keyId, modifiers, (int)k);
};
f.Invoke(ff); // this should be checked if we really need it (InvokeRequired), but it's faster this way
}
示例3: showOKDialog
public DialogResult showOKDialog(Form use_me, String title, String message)
{
if(Environment.UserInteractive) {
if(use_me.InvokeRequired) {
return (DialogResult)use_me.Invoke(new showOKDialogDelegate(showOKDialog), new Object[] {use_me,title,message});
} else {
return MessageBox.Show(use_me,message,title,MessageBoxButtons.OK,MessageBoxIcon.Information,MessageBoxDefaultButton.Button1);
}
} else {
lock(use_me) {
return MessageBox.Show(message,title, MessageBoxButtons.OK,MessageBoxIcon.Information,MessageBoxDefaultButton.Button1,MessageBoxOptions.ServiceNotification);
}
}
}
示例4: showFolderBrowserDialog
public DialogResult showFolderBrowserDialog(Form daddy, FolderBrowserDialog baby)
{
if(daddy.InvokeRequired) {
return (DialogResult)daddy.Invoke(new showFolderBrowserDialogDelegate(showFolderBrowserDialog), new Object[] { daddy, baby });
} else {
lock(daddy) {
lock(baby) {
return baby.ShowDialog(daddy);
}
}
}
}
示例5: show
public void show(Form daddy, Form baby)
{
if(daddy.InvokeRequired) {
daddy.Invoke(new showDelegate(show), new Object[] { daddy, baby });
} else {
lock(daddy) {
lock(baby) {
baby.Show(daddy);
}
}
}
}
示例6: clearToolStripItems
public void clearToolStripItems(Form in_me, ToolStripMenuItem clear_me)
{
if(in_me.InvokeRequired) {
in_me.Invoke(new clearToolStripItemsDelegate(clearToolStripItems),new Object[] {in_me, clear_me});
} else {
lock(clear_me) {
clear_me.DropDownItems.Clear();
}
}
}
示例7: addToolStripItem
public void addToolStripItem(Form in_me, ToolStripMenuItem to_me, ToolStripMenuItem add_me)
{
if(in_me.InvokeRequired) {
in_me.Invoke(new addToolStripItemDelegate(addToolStripItem),new Object[] {in_me, to_me, add_me});
} else {
lock(to_me) {
to_me.DropDownItems.Add(add_me);
}
}
}