i am new guy here.
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)
{
try
{
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("noreply@whatever.com")));
mail.SendAndSaveCopy(new FolderId(WellKnownFolderName.SentItems, new Mailbox("noreply@whatever.com")));
};
System.Threading.Tasks.Task task = new System.Threading.Tasks.Task(action);
task.Start();
return task;
}
whole References here
Thank you for see this.