public static void ReadFromWriteTo(MtStream src, MtStream dest, Action doneCallback) { #if DEBUG && !SILVERLIGHT Debug.Print("ReadFrom x to y"); #endif try { var readCtx = src.CreateReadingContext(); var writCtx = dest.CreateWritingContext(); Action <byte[], bool> readCallback = null; readCallback = (bytes, atEnd) => { dest.Write(writCtx, bytes); // Continue only if there are more bytes to read ... if (!atEnd) { src.Read(readCtx, readCallback, doneCallback); } }; src.Read(readCtx, readCallback, doneCallback); } catch (Exception e) { throw new Exception("Exception on Stream.readFromTo", e); } }
public static void ReadFromWriteTo(MtStream src, MtStream dest, Action doneCallback) { #if DEBUG && !SILVERLIGHT Debug.Print("ReadFrom x to y"); #endif try { var readCtx = src.CreateReadingContext(); var writCtx = dest.CreateWritingContext(); Action<byte[], bool> readCallback = null; readCallback = (bytes, atEnd) => { dest.Write(writCtx, bytes); // Continue only if there are more bytes to read ... if (!atEnd) { src.Read(readCtx, readCallback, doneCallback); } }; src.Read(readCtx, readCallback, doneCallback); } catch (Exception e) { throw new Exception("Exception on Stream.readFromTo", e); } }