I'm trying to save an attachment I get from a byte from a webservice. The problem is that my code continues even before the completed event of the method could have been called. Is there some way to let the application wait for that event.
This is the part where I save the attachment as byes:
var temporaryStream = new MemoryStream();
foreach (var attachment in msg.Attachments.Where(attachment =>
And this is how I try to get the byte:
byte result = null;
_popClient.SaveAttachmentCompleted += (sender, e) =>
if (e.Error != null) return;
result = e.Result;
The Async call takes to long to finish... Is there any way to speed the process of fetching the attachment up or another way to fix that problem?