本文整理汇总了C#中System.Action.Do方法的典型用法代码示例。如果您正苦于以下问题:C# Action.Do方法的具体用法?C# Action.Do怎么用?C# Action.Do使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Action
的用法示例。
在下文中一共展示了Action.Do方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Call
public void Call(
Action<bool> doneCallback = null,
Action succeeded = null,
Action failed = null,
[CallerFilePath] string filePath = null,
[CallerLineNumber] int lineNumber = 0)
{
/* var sourceFileInfo = SourceFileInformationUtils.Format(filePath, lineNumber);
LogManager<AsyncCall>.Logger.Info(
"Async operation is beign started ({0})".Fmt(sourceFileInfo));*/
var task = _asyncLambda();
if (_isModal)
{
task = task.Modal(_message, filePath, lineNumber);
}
task.ContinueWith(
t =>
{
try
{
t.Exception.With(e => e.InnerException).DoTypeSwitch(
(KnownOperationException ex) =>
{
var handled = _knownOperationExceptionHandler.Return(
h => h(ex), (bool?)null);
if (handled.GetValueOrDefault(false))
{
return;
}
if (!handled.HasValue)
{
handled = _operationExceptionHandler.Return(
h => h(ex), false);
if (handled.GetValueOrDefault(false))
{
return;
}
}
//ex.Operation.ShowErrorMessage();
},
(OperationException ex) =>
{
var handled = _operationExceptionHandler.Return(h => h(ex), false);
if (handled)
{
return;
}
ex.RethrowOperationException(filePath, lineNumber);
},
ex => t.Exception.CheckExceptionAndWrap(filePath, lineNumber));
}
finally
{
if (t.Exception == null)
{
succeeded.Do(c => c());
}
else
{
failed.Do(c => c());
}
doneCallback.Do(c => c(t.Exception == null));
/* LogManager<AsyncCall>.Logger.Info(
"Async operation is finished ({0})".Fmt(sourceFileInfo));*/
}
},
CancellationToken.None,
TaskContinuationOptions.None,
TaskScheduler.FromCurrentSynchronizationContext())
.HandleExceptions(filePath, lineNumber);
}