Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have a complicate problem.
I am using .net 4.0 MVC 4, add References about Microsoft BLC for using async, await.
and wrote
await System.Threading.Tasks.TaskEx.WhenAll(tl);
for wait Threads work ends of course.
But error pops out here.
Error 13 The type or namespace name 'TaskEx' does not exist in the namespace 'System.Threading.Tasks' (are you missing an assembly reference?)
I tested many times another Project on another Solution, but it's work. not like this.
Any ideas for little help?
whole Method here.
public async void SendEmailEwsAsync(string subject, string mailBody, string fileName)
List<System.Threading.Tasks.Task> tl = new List<System.Threading.Tasks.Task>();
foreach (var kvp in Receivers)
EmailMessage mail = CreateMailEws(subject, mailBody);
mail.ToRecipients.Add(kvp.Value);
if (!this.TestFlag)
mail.Attachments.AddFileAttachment(string.Format(fileName, EmailNamePair[kvp.Value]), kvp.Key);
tl.Add(TaskSendAsync(mail));
this.CurrentCursor++;
await System.Threading.Tasks.TaskEx.WhenAll(tl); //error here
catch (Exception e)
throw e;
finally
this.IsEnd = true;
private System.Threading.Tasks.Task TaskSendAsync(EmailMessage mail)
Action action = delegate()
mail.Save(new FolderId(WellKnownFolderName.Drafts, new Mailbox("[email protected]")));
mail.SendAndSaveCopy(new FolderId(WellKnownFolderName.SentItems, new Mailbox("[email protected]")));
System.Threading.Tasks.Task task = new System.Threading.Tasks.Task(action);
task.Start();
return task;
whole References here
Project References List
Thank you for see this.
–
–
–
You do not need to reference TaskEx, and you can do WaitAll instead of WhenAll
// Wait for all tasks in list to complete
Task.WaitAll(tl);
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.