TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Gnanavel Sekar
NA
8.4k
7.3m
how to handle child Exception when it's in async
Jul 11 2017 2:22 AM
hi friends, i one method, that method contains more than 10 child methods with async, i would like to capture the exceptions from child in parent method, just see the my code for clearance
public static class StateMachineCommand
{
/// <summary>
/// Creates a DelegateCommand using a trigger and a state machine.
/// The command can be executed if the trigger can be executed on the current state machine status and the specified "CanExecute" function is null or returns true.
/// When the command is executed the specified action is executed and then the trigger is fired
/// </summary>
/// <typeparam name="TState">State machine status type.</typeparam>
/// <typeparam name="TTrigger">State machine status trigger.</typeparam>
/// <param name="stateMachine">A state machine instance</param>
/// <param name="trigger">A trigger.</param>
/// <param name="execute">Action to execute when the command is executed.</param>
/// <param name="canExecute">The command can be executed only if this function is null or return true and the current status of the machine supports the trigger.</param>
public static DelegateCommand CreateCommand<TState, TTrigger>(this StateMachine<TState, TTrigger> stateMachine, TTrigger trigger, Action execute = null, Func<bool> canExecute = null)
{
if (canExecute == null)
{
canExecute = () => true;
}
if (execute == null)
{
execute = () => { };
}
return new DelegateCommand(
executeMethod: () =>
{
execute(); ----->here am excuting all child methods and it's will not return any value and it's all async, if any error i caught here means i need to stop the following code whichever mentioned in green color
if (stateMachine.CanFire(trigger))
{
stateMachine.Fire(trigger);
}
},
canExecuteMethod: () => canExecute());
}
thanks in advance
Reply
Answers (
4
)
Enable tab from a Bootstrap Tab Menu
Connecting Ms Access database from outside not inside Debug