Hi have asp.net 4.0 webfrom with UpdatePanel and AjaxControlsToolKit.
Inside this web from I have a Task who runs on a generic list of recipients and send them the mail while also saving it as a pdf file in a files server and uploading it via web service to the organization ERP system.
I want to catch/log errors during the task process and in the end to show them to the user and let him run the process on them again.
- Task sendMailTask =
- Task.Factory.StartNew((stateObj) =>
- {
-
- },2000);
- try
- {
- if (!sendMailTask.IsCanceled && !sendMailTask.IsFaulted)
- {
- StatusMessagesContainerModalDialog.Attributes["class"] = "modal-content alert-success";
- StatusMessagesContainer.CssClass = "text-center";
- Status.Text = "Your email was sent";
- StatusMessagesModalPopup.Show();
- }
- }
- catch (AggregateException ex)
- {
- StatusMessagesContainerModalDialog.Attributes["class"] = "modal-content alert-warning";
- StatusMessagesContainer.CssClass = "text-center";
- Status.Text = "Error occured";
- StatusMessagesModalPopup.Show();
- }
How can update the ui?
Right now the user get a message that the email was sent immediately before the task completed and when i try to update the ui from the task itself even when using ContinueWith nothing happens in the ui tread and the user does not see the data i want him to see.