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


C# Action.EndInvoke方法代码示例

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


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

示例1: Main

	/* expected exit code: 255 */
	static void Main (string[] args)
	{
		if (Environment.GetEnvironmentVariable ("TEST_UNHANDLED_EXCEPTION_HANDLER") != null)
			AppDomain.CurrentDomain.UnhandledException += (s, e) => {};

		ManualResetEvent mre = new ManualResetEvent (false);

		var a = new Action (() => { try { throw new CustomException (); } finally { mre.Set (); } });
		var ares = a.BeginInvoke (null, null);

		if (!mre.WaitOne (5000))
			Environment.Exit (2);

		try {
			a.EndInvoke (ares);
			Environment.Exit (4);
		} catch (CustomException) {
			/* expected behaviour */
			Environment.Exit (255);
		} catch (Exception ex) {
			Console.WriteLine (ex);
			Environment.Exit (3);
		}

		Environment.Exit (5);
	}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:27,代码来源:unhandled-exception-2.cs

示例2: CheckoutFileIfRequired

        private static void CheckoutFileIfRequired(_DTE dte, String fileName)
        {
            _checkOutAction = (String fn) => dte.SourceControl.CheckOutItem(fn);

            var sc = dte.SourceControl;
            if (sc != null && sc.IsItemUnderSCC(fileName) && !sc.IsItemCheckedOut(fileName))
                _checkOutAction.EndInvoke(_checkOutAction.BeginInvoke(fileName, null, null));
        }
开发者ID:Exclr8,项目名称:CloudCore,代码行数:8,代码来源:base.cs

示例3: BatchSave_Info

 public void BatchSave_Info(List<Entity.CurrencyInfo> values)
 {
     var action = new Action(() => { service.BatchSave_Info(values); });
     action.BeginInvoke((ar) =>
     {
         action.EndInvoke(ar);
         ServerInstrumentation.Current.Queue(-1);
     }, action);
 }
开发者ID:kainhong,项目名称:CurrencyStore,代码行数:9,代码来源:RemoteAgent.cs

示例4: Start

		public void Start(IWin32Window owner, int fileCount, Action action) {
			progressBar.Maximum = fileCount;
			Show(owner);

			action.BeginInvoke(
					ar => {
						action.EndInvoke(ar);
						Action hideAction = EndProgress;
						Invoke(hideAction);
					}, null);
		}
开发者ID:audioglider,项目名称:OpenCodeCoverageFramework,代码行数:11,代码来源:ProgressForm.cs

示例5: AsyncCallAndWait

 public static bool AsyncCallAndWait(Action action)
 {
     IAsyncResult result = action.BeginInvoke(null, null);
     try {
         action.EndInvoke(result);
     }
     catch (Exception) {
         return false;
     }
     return true;
 }
开发者ID:pcmind,项目名称:yolo-octo-sansa,代码行数:11,代码来源:Servidor.cs

示例6: Restore

 public void Restore(string cloudName)
 {
     Action action = new Action(() =>
     {
         if (DownloadFromCloud(cloudName))
         {
             MergeDB(cloudName);
             MessageBox.Show("云还原成功");
         }
     });
     action.BeginInvoke((ar) => action.EndInvoke(ar), action);
 }
开发者ID:lzcj4,项目名称:Game28,代码行数:12,代码来源:CloudDBTool.cs

示例7: Wait

        private bool Wait(Action action, int timeout)
        {
            var handle = action.BeginInvoke(null, null);

            if (handle.AsyncWaitHandle.WaitOne(timeout))
            {
                action.EndInvoke(handle);

                return false;
            }

            return true;
        }
开发者ID:pbering,项目名称:SitecoreLogglyAppender,代码行数:13,代码来源:HttpServer.cs

示例8: RunSync

        public bool RunSync(Action<CancelEventArgs> action, TimeSpan maxRuntime)
        {
            if (maxRuntime.TotalMilliseconds <= 0)
            {
                throw new ArgumentOutOfRangeException("maxRuntime");
            }

            CancelEventArgs args = new CancelEventArgs(false);
            IAsyncResult functionResult = action.BeginInvoke(args, null, null);
            WaitHandle waitHandle = functionResult.AsyncWaitHandle;
            if (!waitHandle.WaitOne(maxRuntime))
            {
                args.Cancel = true; // flag to worker that it should cancel!
                ThreadPool.UnsafeRegisterWaitForSingleObject(waitHandle,
                    (state, timedOut) => action.EndInvoke(functionResult),
                    null, -1, true);
                return false;
            }

            action.EndInvoke(functionResult);
            return true;
        }
开发者ID:osamede,项目名称:social_listen,代码行数:22,代码来源:ThreadTaskRunnerService.cs

示例9: Bakcup

        public void Bakcup(string cloudName)
        {
            string dbPath = DBHelper.GetDBPath(DBHelper.DBName);

            Action action = new Action(() =>
            {
                if (OSSHelper.UploadFile(dbPath, cloudName))
                {
                    MessageBox.Show("云备份成功");
                }
            });
            action.BeginInvoke((ar) => action.EndInvoke(ar), action);
        }
开发者ID:lzcj4,项目名称:Game28,代码行数:13,代码来源:CloudDBTool.cs

示例10: RegisterSchedule

 /// <summary>
 /// オペレーションスケジュールを登録します。<para />
 /// 実行可能な場合はすぐに実行します。
 /// </summary>
 /// <param name="operation">オペレーション(サブスレッドで実行されます)</param>
 /// <param name="condition">発動条件、またはNULL</param>
 internal static void RegisterSchedule(Action operation, Func<bool> condition)
 {
     if (condition == null || condition())
     {
         operation.BeginInvoke((iar) => operation.EndInvoke(iar), null);
     }
     else
     {
         lock (queuelock)
         {
             queuings.Add(new QueuedOperation(operation, condition));
         }
     }
 }
开发者ID:karno,项目名称:Lycanthrope,代码行数:20,代码来源:Scheduler.cs

示例11: ExportMySQL

		public static void ExportMySQL()
		{
			if (!CMOptions.ModuleEnabled || !CMOptions.MySQLEnabled || !CMOptions.MySQLInfo.IsValid())
			{
				if (_Connection != null)
				{
					_Connection.Dispose();
					_Connection = null;
				}

				return;
			}

			if (_Connection != null && !_Connection.IsDisposed)
			{
				return;
			}

			CMOptions.ToConsole("Updating MySQL database...");
			
			VitaNexCore.TryCatch(
				() =>
				{
					_Connection = new MySQLConnection(CMOptions.MySQLInfo);
					_Connection.ConnectAsync(0, true,() =>
					{
						var a = new Action(UpdateMySQL);

						a.BeginInvoke(
							r =>
							{
								a.EndInvoke(r);
								UpdateMySQL();
							},
							null);
					});
				},
				x =>
				{
					if (_Connection != null)
					{
						_Connection.Dispose();
						_Connection = null;
					}

					CMOptions.ToConsole(x);
				});
		}
开发者ID:greeduomacro,项目名称:UO-Forever,代码行数:48,代码来源:Conquests_MySQL.cs

示例12: SaveAsync

    public static void SaveAsync(IStorableContent content, string filename, bool compressed, Action<IStorableContent, Exception> savingCompletedCallback) {
      if (instance == null) throw new InvalidOperationException("ContentManager is not initialized.");
      var action = new Action<IStorableContent, string, bool>(instance.SaveContent);
      action.BeginInvoke(content, filename, compressed, delegate(IAsyncResult result) {
        Exception error = null;
        try {
          action.EndInvoke(result);
          content.Filename = filename;
        }
        catch (Exception ex) {
          error = ex;
        }
        savingCompletedCallback(content, error);
      }, null);

    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:16,代码来源:ContentManager.cs

示例13: Processor

 public void Processor(bool async = false)
 {
     var items = this.Reset();
     if (async)
     {
         Processor(items);
     }
     else
     {
         var action = new Action(() => Processor(items));
         action.BeginInvoke((ar) =>
         {
             action.EndInvoke(ar);
         }, action);
     }
 }
开发者ID:kainhong,项目名称:CurrencyStore,代码行数:16,代码来源:StoreItem.cs

示例14: Processor

 public void Processor(bool async = false)
 {
     var items = this.Reset();
     if (async)
     {
         Processor(items);
     }
     else
     {
         var action = new Action(() => Processor(items));
         action.BeginInvoke((ar) =>
         {
             action.EndInvoke(ar);
             ServerInstrumentation.Current.Queue(-1);
         }, action);
     }
 }
开发者ID:kainhong,项目名称:CurrencyStore,代码行数:17,代码来源:StoreItem.cs

示例15: Do

        public static void Do(Action<ManualResetEvent> callback, Action action, int timeout)
        {
            var evt = new ManualResetEvent(false);

            IAsyncResult resultAction = null;
            IAsyncResult resultCallback = callback.BeginInvoke(evt, ar => resultAction = action.BeginInvoke(ar2 => evt.Set(), null), null);

            if (evt.WaitOne(timeout))
            {
                callback.EndInvoke(resultCallback);
                action.EndInvoke(resultAction);
            }
            else
            {
                throw new TimeoutException();
            }
        }
开发者ID:chihchi,项目名称:funtown-csharp-sdk,代码行数:17,代码来源:TestExtensions.cs


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