本文整理汇总了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);
}
示例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));
}
示例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);
}
示例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);
}
示例5: AsyncCallAndWait
public static bool AsyncCallAndWait(Action action)
{
IAsyncResult result = action.BeginInvoke(null, null);
try {
action.EndInvoke(result);
}
catch (Exception) {
return false;
}
return true;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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));
}
}
}
示例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);
});
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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();
}
}