My OperationContract
:
public List<MessageDTO> GetMessages()
{
List<MessageDTO> messages = new List<MessageDTO>();
foreach (Message m in _context.Messages.ToList())
{
messages.Add(new MessageDTO()
{
MessageID = m.MessageID,
Content = m.Content,
Date = m.Date,
HasAttachments = m.HasAttachments,
MailingListID = (int)m.MailingListID,
SenderID = (int)m.SenderID,
Subject = m.Subject
});
}
return messages;
}
In Service Reference configuration I checked the option "Generate asynchronous operations". How do I use the generated GetMessagesAsync()
? In the net I found examples that use AsyncCallback
, however I'm not familiar with that. Is there a way to use it in some friendly way like async
and await
keywords in .NET 4.5? If not, what should I do to invoke the method asynchronously?