FlushAsync alternative in Windows Phone
-
lunes, 21 de mayo de 2012 15:21
Hello everyone,
I have a code working on Windows 8 but I can't make it work on Windows phone :
using (Stream requestStream = await request.GetRequestStreamAsync()) using (StreamWriter writer = new StreamWriter(requestStream)) { await requestStream.WriteAsync(buffer, 0, buffer.Length); await requestStream.FlushAsync(); }The FLushAsync method doesn't exists in Windows Phone. I'm asking you if you know an alternative to this method.
Thanks.
Todas las respuestas
-
miércoles, 23 de mayo de 2012 16:17Moderador
Hi corbicorben-
As a workaround, you could add your own extension method to Stream, e.g.
public static Task FlushAsync(this Stream stream)
{
return Task.Factory.StartNew(() => stream.Flush());
}That will at least allow the code to function and remain responsive.
- Propuesto como respuesta Stephen Toub - MSFTMicrosoft Employee, Moderator miércoles, 23 de mayo de 2012 16:17
- Marcado como respuesta corbicorben viernes, 25 de mayo de 2012 14:30
-
viernes, 25 de mayo de 2012 14:32Thank you, I didn't know about the Factory property, it was blocking me a bit.

