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


C# Form.Invoke方法代码示例

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


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

示例1: Run

        public override void Run(ServiceController[] services, Form mainForm, DataGrid serviceGrid)
        {
            var addedMachine = QuickDialog2.DoQuickDialog("Add A Machine's Services", "Machine Name:",".","Pattern  ^(Enable|EPX):","");

            if (addedMachine != null)
            {

                MachineName = addedMachine[0];
                this.SearchPattern = addedMachine[1];
                try
                {
                    DataGrid dgrid = serviceGrid;

                    this.addView = (DataView)dgrid.DataSource;

                    CurrencyManager bm = (CurrencyManager)dgrid.BindingContext[this.addView];
                    ArrayList arrSelectedRows = new ArrayList();

                    this.addView = (DataView)bm.List;

                    mainForm.Invoke(new InvokeDelegate(this.AddMachineInGUIThread));

                    serviceGrid.Refresh();

                }
                finally
                {
                    addedMachine = null;
                    addView = null;
                }

            }
        }
开发者ID:kcsampson,项目名称:Kexplorer,代码行数:33,代码来源:AddMachineScript.cs

示例2: MainWindow

        public MainWindow(Form parent, OGameBot bot, UGInfos forumInfos)
        {
            _bot = bot;
            _parent = parent;
            InitializeComponent();
            forumUserLabel.Text = @"User: " + forumInfos.User;
            forumUIDLabel.Text = @"Post: " + forumInfos.Post;
            forumPostLabel.Text = @"UID: " + forumInfos.UID;
            forumStatusLabel.Text = @"Status: " + forumInfos.Status;
            PopulateAddBuildingList();

            _bot.BeganBuild += (o, b) => DisplayLogMessage(@"Iniziata la costruzione di " + b.GetDescription());

            _bot.Built += (o, b) =>
                              {
                                  DisplayLogMessage(@"Terminata la costruzione di " + b.GetDescription());
                                  buildingListView.Invoke(new Action(() => buildingListView.Items.RemoveAt(0)));
                              };

            _bot.BuildingUnavaiable += (o, b) => DisplayLogMessage(@"Non puoi costruire " + b.GetDescription() + ", verrà spostato in fondo alla coda.");
            _bot.NotEnoughResources += (o, b) =>
                                           {
                                               if (_notEnoughResourcesCount == 0)
                                                   DisplayLogMessage(@"Risorse non sufficenti per " + b.GetDescription() +
                                                                     ", in attesa");
                                               _notEnoughResourcesCount = ++_notEnoughResourcesCount%20;
                                           };

            _bot.InConstruction += o =>
                                       {
                                           if (_inConstructionCount == 0)
                                               DisplayLogMessage(
                                                   @"E' già presente un edificio in costruzione, in attesa");
                                           _inConstructionCount = ++_inConstructionCount%20;
                                       };
            _bot.Stopped += o => _parent.Invoke(new Action(Close));
        }
开发者ID:D4n13le,项目名称:OGameBot,代码行数:37,代码来源:MainWindow.cs

示例3: Close

 public static void Close(Form form)
 {
     if (form.InvokeRequired)
         form.Invoke(new CloseDelegate(Close), form);
     else
         form.Close();
 }
开发者ID:greeduomacro,项目名称:phoenix,代码行数:7,代码来源:Safe.cs

示例4: GetDetails

 /// <summary>
 /// Will open a form that will ask for connection details (with option for default props) and attempt to ping target to see if it is possible to establish connection
 /// </summary>
 /// <param name="parent">Parent form that this form will be opened on</param>
 /// <param name="default_details">The default connection details to be inserted</param>
 /// <param name="forceTesting"></param>
 public static ConnectionDetails GetDetails(Form parent, ConnectionDetails default_details, bool forceTesting = true) {
     UserConnectionDetailsRequester getter = null;
     parent.Invoke(() => {
                       getter = new UserConnectionDetailsRequester(forceTesting, default_details);
                       getter.ShowDialog(parent);
                   });
     return getter.Results();
 }
开发者ID:Nucs,项目名称:nlib,代码行数:14,代码来源:UserConnectionDetailsRequester.cs

示例5: UIActor

        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="mainApplicationForm">The application's main form</param>
        public UIActor(Form mainApplicationForm)
        {
            m_applicationForm = mainApplicationForm;

            m_applicationForm.Invoke((Action)(() =>
            {
                if (Actor.CurrentActor != null) Actor.CurrentActor = this;
            }));
        }
开发者ID:wow4all,项目名称:evemu_server,代码行数:13,代码来源:UIActor.cs

示例6: ShowErrorCallback

			private delegate void ShowErrorCallback(Form frmWindow, string strMessage, Exception objException); // Permite llamadas asíncronas para mostrar un mensaje
			
		/// <summary>
		///		Muestra un cuadro de mensaje
		/// </summary>
		public static void ShowMessage(Form frmWindow, string strMessage)
		{ // InvokeRequired compara el ID del hilo llamante con el ID del hilo creador, si son diferentes devuelve True
				if (frmWindow != null && frmWindow.InvokeRequired)
					{	ShowMessageCallback fncCallback = new ShowMessageCallback(ShowMessage);
					
							frmWindow.Invoke(fncCallback, new object[] { frmWindow, strMessage });
					}
				else
					MessageBox.Show(frmWindow, strMessage, Application.ProductName);
		}
开发者ID:jbautistam,项目名称:CopySolutionsVisualStudio,代码行数:15,代码来源:Helper.cs

示例7: DrawingSystem

 public DrawingSystem(Form form, EntityManager manager)
     : base(manager)
 {
     _form = form;
     _form.Invoke(new Action(() =>
     {
         _context = BufferedGraphicsManager.Current;
         _buffer = _context.Allocate(_form.CreateGraphics(), _form.DisplayRectangle);
     }));
 }
开发者ID:jjvdangelo,项目名称:ESTest,代码行数:10,代码来源:DrawingSystem.cs

示例8: CloseForm

 public static void CloseForm(Form form)
 {
     // Check if the form need to be invoked.
     if (form.InvokeRequired)
         // Invoke the form with the appropiate delegate.
         form.Invoke(new Action<Form>(CloseForm), form);
     else
         // Directly close the form.
         form.Close();
 }
开发者ID:Woodje,项目名称:MailClient,代码行数:10,代码来源:ComponentChanges.cs

示例9: Invoke

 public static void Invoke(Form form, AsyncAction action)
 {
     if (!form.InvokeRequired)
     {
         action();
     }
     else
     {
         form.Invoke((DispatcherInvoker)Invoke, form, action);
     }
 }
开发者ID:andrusender,项目名称:YesPos,代码行数:11,代码来源:Dispatcher.cs

示例10: SetText

 public static void SetText(Form form, Control ctrl, string text)
 {
     if (ctrl.InvokeRequired)
     {
         SetTextCallback stc = SetText;
         form.Invoke(stc, new object[] {form, ctrl, text});
     }
     else
     {
         ctrl.Text = text;
     }
 }
开发者ID:Garfounkel,项目名称:TeslaSplit,代码行数:12,代码来源:Program.cs

示例11: GameWindow

        /// <summary>
        /// Initializes a new GameWindow class.
        /// </summary>
        /// <param name="handle">The Handle.</param>
        internal GameWindow(IntPtr handle)
        {
            _surface = (Form) Control.FromHandle(handle);
            _surfaceStyle = SurfaceStyle.Normal;
            _surfaceLayout = new SurfaceLayout(true, false, true);
            CursorVisibility = false;
            _surface.FormClosing += _surface_FormClosing;
            _surface.Activated += _surface_Activated;
            _surface.Deactivate += _surface_Deactivate;

            MethodInvoker br = delegate { _surface.KeyPreview = true; };
            _surface.Invoke(br);
        }
开发者ID:ThuCommix,项目名称:Sharpex2D,代码行数:17,代码来源:GameWindow.cs

示例12: SafeGetWindowHandle

		/// <summary>
		/// Safely retrieves the window's handle. The events the InstanceManager are on a separate thread
		/// forcing us to marshall the calls back to the window's thread.
		/// </summary>
		/// <param name="window">The window to retrieve the handle for.</param>
		/// <returns></returns>
		public static IntPtr SafeGetWindowHandle(Form window)
		{
			if (window == null)
			{
				return IntPtr.Zero;
			}

			if (window.InvokeRequired)
			{
				return (IntPtr)window.Invoke(new GetWindowHandleDelegate(SafeGetWindowHandle), window);
			}

			return window.Handle;
		}
开发者ID:FireBall1725,项目名称:Carbon.Framework,代码行数:20,代码来源:WindowUtilities.cs

示例13: ActivateParentForm

        private static void ActivateParentForm(Form parentForm)
        {
            if (parentForm != null)
            {
                //HandleRef href = new HandleRef(ParentForm, ParentForm.Handle);
                //SetForegroundWindow(href);

                parentForm.Invoke(new Action(() => { parentForm.Activate(); }));
            }
            else if (ApplicationService.Current.MainForm != null)
            {
                ApplicationService.Current.MainForm.Invoke(new Action(() => { ApplicationService.Current.MainForm.Activate(); }));
            }
        }
开发者ID:JodenSoft,项目名称:JodenSoft,代码行数:14,代码来源:ProgressService.cs

示例14: PrintText

 public void PrintText(string txt, TextBox printBox, Form owner)
 {
     if (printBox.InvokeRequired)
     {
         invokeTextBox d = new invokeTextBox(PrintText);
         owner.Invoke(d, txt, printBox, owner);
     }
     else
     {
         printBox.Text += txt;
         printBox.Select(printBox.Text.Length, 0);
         printBox.ScrollToCaret();
     }
 }
开发者ID:Radon222,项目名称:AsciiConverter,代码行数:14,代码来源:PrinterController.cs

示例15: SetControlText

        public static void SetControlText(this Control control, Form CFrom, string text)
        {
            if (CFrom.InvokeRequired)
            {
                ControlTextMethod controlTextMethod = SetControlText;
                CFrom.Invoke(controlTextMethod, new object[] { control, CFrom, text });
            }
            else
            {
                control.Text = text;
            }

            Application.DoEvents();
        }
开发者ID:GeneralRookie,项目名称:BackgroundWorkerTest,代码行数:14,代码来源:WinControlExtension.cs


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