Can we use Try/Catch Within QueuedTask.Run()

By | July 19, 2018
Questions:

Can we use Try/Catch within QueuedTask.Run()?

I have feeling that Try/Catch should be outside QueuedTask.Run() but I don’t have reason for that. Please clarify whether to keep in or out of QueuedTask.Run()

public ICommand CmdEdit
{
    get
    {
        return _cmdEdit ?? (_cmdEdit = new RelayCommand(() =>
        {
            QueuedTask.Run(() =>
            {
                try
                {
                    if (_selectedObj != null && SelectedObjs.Count() == 1)
                    {
                        OnEditObj(_selectedObj);
                    }
                }
                catch (Exception ex)
                {
                    DialogService.ShowPrompt(ex, null, DialogServiceMessage.Message_EditError, DialogServiceCaption.Caption_Exception, DialogServiceButtons.Ok, DialogServiceIcon.Exclamation);
                    OneGeo.ExceptionLogger.EventLogger.Log(ex);
                }
            });
        }, () => (_selectedObj != null && _selectedObjs.Count() == 1)));
    }
}
Answers:
Category: C#

Leave a Reply

Your email address will not be published. Required fields are marked *