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


C# MethodInvoker类代码示例

本文整理汇总了C#中MethodInvoker的典型用法代码示例。如果您正苦于以下问题:C# MethodInvoker类的具体用法?C# MethodInvoker怎么用?C# MethodInvoker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: DeterMineCall

 private void DeterMineCall(MethodInvoker method)
 {
     if (InvokeRequired && !this.IsDisposed)
         Invoke(method);
     else
         method();
 }
开发者ID:shepherds126,项目名称:12306_Helper,代码行数:7,代码来源:FormWebData.cs

示例2: StartTry

 public static Thread StartTry(MethodInvoker code, ErrorHandler on_error = null, MethodInvoker on_finally = null, bool background = true)
 {
     Thread t = new Thread(
         () => {
             try
             {
                 code.Invoke();
             }
             catch (ThreadAbortException e)
             {
                 Thread.ResetAbort();
             }
             catch (Exception e)
             {
                 if (on_error != null)
                     on_error.Invoke(e);
                 else
                     Message.Error(e);
             }
             finally
             {
                 on_finally?.Invoke();
             }
         }
     );
     t.IsBackground = background;
     t.Start();
     return t;
 }
开发者ID:sergeystoyan,项目名称:CliverBot,代码行数:29,代码来源:ThreadRoutines.cs

示例3: UpdateState

 private void UpdateState()
 {
     MethodInvoker invoker = new MethodInvoker(delegate()
                 {
                     if ((File.GetAttributes(m_originalSolutionFullPath) & FileAttributes.ReadOnly) != 0)
                     {
                         m_labelState.ForeColor = Color.Red;
                         m_labelState.Text = "ReadOnly";
                         m_labelStateDescription.Visible = true;
                         m_buttonYes.Enabled = false;
                     }
                     else
                     {
                         m_labelState.ForeColor = Color.Black;
                         m_labelState.Text = "Writable";
                         m_labelStateDescription.Visible = false;
                         m_buttonYes.Enabled = true;
                     }
                 });
     if (m_labelState.InvokeRequired)
     {
         this.Invoke(invoker);
     }
     else
     {
         invoker.Invoke();
     }
 }
开发者ID:m3zercat,项目名称:slntools,代码行数:28,代码来源:UpdateOriginalSolutionForm.cs

示例4: CheckAvailable

        /// <summary>
        /// Check to see if an update to the application is available.
        /// </summary>
        /// <param name="available">A <see cref="MethodInvoker"/> delegate which is called if an update is available.</param>
        internal static void CheckAvailable(MethodInvoker available)
        {
            ThreadPool.QueueUserWorkItem(delegate
            {
                CachedWebClient checkUpdate = CachedWebClient.GetInstance();
                string versionInfo = null;

                try
                {
                    versionInfo = checkUpdate.DownloadString(new Uri(BaseUrl + Application.ProductVersion), CacheHours);
                }
                catch (WebException)
                {
                    // Temporary problem downloading the information, try again later
                    return;
                }

                Settings.LastCheckForUpdates = DateTime.Now;

                if (!string.IsNullOrEmpty(versionInfo))
                {
                    versionInfo = versionInfo.Split(new string[] { "\r\n" }, StringSplitOptions.None)[0];

                    if (string.Compare(versionInfo, Application.ProductVersion, StringComparison.Ordinal) > 0)
                    {
                        // There is a new version available
                        available();
                    }
                }

                return;
            });
        }
开发者ID:ribbons,项目名称:RadioDownloader,代码行数:37,代码来源:UpdateCheck.cs

示例5: FTeams

		internal FTeams(ref Common.Interface newCommon)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			CommonCode = newCommon;

			Trace.WriteLine("FTeams: Creating");
			EnableMeInvoker = new MethodInvoker(this.enableMe);

			PopulateTeamsDropDownThreadInvoker += 
				new MethodInvoker(populateTeamsDropDownThread);
			try
			{
				height = this.Size.Height;
				width = this.Size.Width;
			}
			catch(Exception exc)
			{
				Trace.WriteLine("FTeams: Exception during creation:" + exc.ToString());
				throw;
			}
			finally
			{
				Trace.WriteLine("FTeams: Created.");
			}
		}
开发者ID:WinShooter,项目名称:WinShooter-Legacy,代码行数:29,代码来源:FTeams.cs

示例6: UIBlockingInvoke

        /// <summary>
        /// Runs a MethodInvoker delegate on the UI thread from whichever thread we are currently calling from and BLOCKS until it is complete
        /// </summary>
        /// <param name="ivk"></param>
        public void UIBlockingInvoke(MethodInvoker ivk)
        {
            System.Threading.ManualResetEvent UIAsyncComplete = new System.Threading.ManualResetEvent(false);
            UIAsyncComplete.Reset();
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new MethodInvoker(delegate()
                {
                    try
                    {
                        ivk();
                    }
                    finally
                    {
                        UIAsyncComplete.Set();
                    }
                }));

                UIAsyncComplete.WaitOne();
            }
            else
            {
                ivk();
            }
        }
开发者ID:JamesDunne,项目名称:RyanSync,代码行数:29,代码来源:frmMain.cs

示例7: add_Button

 public static Button add_Button(this Control control, string text, int top, int left, int height, int width, MethodInvoker onClick)
 {
     return control.invokeOnThread(
         () =>
             {
                 var button = new Button {Text = text};
                 if (top > -1)
                     button.Top = top;
                 if (left > -1)
                     button.Left = left;
                 if (width == -1 && height == -1)
                     button.AutoSize = true;
                 else
                 {
                     if (width > -1)
                         button.Width = width;
                     if (height > -1)
                         button.Height = height;
                 }
                 button.onClick(onClick);
                 /*if (onClick != null)
                             button.Click += (sender, e) => onClick();*/
                 control.Controls.Add(button);
                 return button;
             });
 }
开发者ID:njmube,项目名称:FluentSharp,代码行数:26,代码来源:WinForms_ExtensionMethods_Button.cs

示例8: Page_Load

        /// <summary>
        /// Load default value to control and other initialize.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                MethodInvoker runHitCount = new MethodInvoker(UpdateHitCount);
                runHitCount.BeginInvoke(CurrentWeb, HttpContext.Current, null, null);
                //dvBG.Attributes.Add("style", "background-image: url('" + DocLibUrl + "/statistic.jpg'); width: 118px; height: 35px;");
                //dvHitCount.InnerText = HitCountNumber.ToString();
                //dvBGDay.Attributes.Add("style", "background-image: url('" + DocLibUrl + "/statistic.jpg'); width: 118px; height: 35px;");
                //dvHitCountDay.InnerText = DayHitCountNumber.ToString();
                //dvBGNow.Attributes.Add("style", "background-image: url('" + DocLibUrl + "/statistic.jpg'); width: 118px; height: 35px;");
                //dvHitCountNow.InnerText = CurrentHitCountNumber.ToString();
                //dvBGWeek.Attributes.Add("style", "background-image: url('" + DocLibUrl + "/statistic.jpg'); width: 118px; height: 35px;");
                //dvHitCountWeek.InnerText = WeekHitCountNumber.ToString();
                //dvBGMonth.Attributes.Add("style", "background-image: url('" + DocLibUrl + "/statistic.jpg'); width: 118px; height: 35px;");
                //dvHitCountMonth.InnerText = MonthHitCountNumber.ToString();
                //dvBGYesterday.Attributes.Add("style", "background-image: url('" + DocLibUrl + "/statistic.jpg'); width: 118px; height: 35px;");
                //dvHitCountYesterday.InnerText = YesterdayHitCountNumber.ToString();

                tdAll.InnerText = HitCountNumber.ToString();
                tdToday.InnerText = DayHitCountNumber.ToString();
                lblCurrent.Text = "<span id='spCurrent'>" + CurrentHitCountNumber.ToString() + "</span>";
                tdThisWeek.InnerText = WeekHitCountNumber.ToString();
                tdThisMonth.InnerText = MonthHitCountNumber.ToString();
                tdYesterday.InnerText = YesterdayHitCountNumber.ToString();
            }
        }
开发者ID:setsunafjava,项目名称:vpsp,代码行数:32,代码来源:HitCountUC.ascx.cs

示例9: FloodFillDrawer

 public FloodFillDrawer(PolygonsContainer data, MethodInvoker ImageRefresher = null)
 {
     this.ImageRefresher = ImageRefresher;
     this.data = data;
     InitializeFloodFillStrategies();
     floodFillerStrategy = strategiesList[0];
 }
开发者ID:idenx,项目名称:FloodFiller,代码行数:7,代码来源:FloodFillDrawer.cs

示例10: InvokeIfRequired

 private void InvokeIfRequired(MethodInvoker _delegate)
 {
     if (this.InvokeRequired)
         this.BeginInvoke(_delegate);
     else
         _delegate();
 }
开发者ID:Green-Bug,项目名称:nunit-gui,代码行数:7,代码来源:XmlView.cs

示例11: MarshalToForm

 private void MarshalToForm(MethodInvoker code)
 {
     if (m_form.InvokeRequired)
         m_form.BeginInvoke(code);
     else
         code();
 }
开发者ID:wjrogers,项目名称:heavyduck.utilities,代码行数:7,代码来源:ProgressDialog.cs

示例12: InvokeIfRequired

 private static void InvokeIfRequired(ISynchronizeInvoke control, MethodInvoker action)
 {
     if (control.InvokeRequired)
         control.Invoke(action, new object[0]);
     else
         action();
 }
开发者ID:b1f6c1c4,项目名称:MineSweeperProb,代码行数:7,代码来源:MineSweeper.cs

示例13: ShortcutAction

		public ShortcutAction(Keys k, bool ctrl, bool editorMustBeFocused, MethodInvoker func)
		{
			Key = k;
			Ctrl = ctrl;
			EditorMustBeFocused = editorMustBeFocused;
			fMethodInvoker = func;
		}
开发者ID:Megamatt01,项目名称:peggle-edit,代码行数:7,代码来源:ShortcutAction.cs

示例14: InvokeIfRequired

 public static void InvokeIfRequired(this ISynchronizeInvoke control, MethodInvoker action)
 {
     if (control.InvokeRequired)
         control.Invoke(action, null);
     else
         action();
 }
开发者ID:celeron533,项目名称:marukotoolbox,代码行数:7,代码来源:Supplements.cs

示例15: Execute

 public override void Execute()
 {
     string msg = "";
     if (AppContext.IsAppInitializing && AppContext.IsGetSignalList && AppContext.SignalDatas.Count > 0)
     {
         signals = new Signal[AppContext.SignalDatas.Count];
         AppContext.SignalDatas.CopyTo(signals);
         MethodInvoker mi = new MethodInvoker(InitPriceList);
         priceListView.Invoke(mi);
         mi = new MethodInvoker(InitSignalList);
         signalListView.Invoke(mi);
         mi = new MethodInvoker(InitStatList);
         statListView.Invoke(mi);
     }
     else if (AppContext.IsAppInitializing && AppContext.IsGetSymbolPrices && AppContext.SymbolPrices.Count > 0)
     {
         MethodInvoker mi = new MethodInvoker(InitPriceList);
         priceListView.Invoke(mi);
         AppContext.IsStatListInitialized = true;
         AppContext.IsSignalListInitialized = true;
     }
     else
     {
         if (AppSetting.STATUS == AppSetting.TEST_ACCOUNT)  //  || AppSetting.STATUS == AppSetting.ADMIN_ACCOUNT
         {
             msg = NetHelper.BuildMsg(Protocol.C0004_1, new string[] { "2" });
         }
         else
         {
             msg = NetHelper.BuildMsg(Protocol.C0004_1, new string[] { "0" });
         }
         Send(msg);
     }
 }
开发者ID:harryho,项目名称:demo-fx-trading-platform-prototype,代码行数:34,代码来源:SignalListHandler.cs


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