Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
0
Answer
updating a asp.net 4.0 webform ui controls from a Task
H H
8y
290
1
Reply
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) =>
{
// some code with for loop on a collection of receipents who call another function which try to save the file using the web service in the ERP.
},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.
Post
Reset
Cancel
Answers (
0
)
Next Recommended Forum
Export of a pdf file
Print qr code in windows form c#