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
H H
NA
11
626
updating a asp.net 4.0 webform ui controls from a Task
Dec 26 2016 7:44 AM
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.
Reply
Answers (
0
)
Export of a pdf file
Print qr code in windows form c#