Exemplo n.º 1
0
        public void Write(MtStreamWritingContext ctx, byte[] stuff)
        {
#if DEBUG && !SILVERLIGHT
            Debug.Print("Write");
#endif

            try
            {
                AsyncCallback wroteCallback = null;
                wroteCallback = r =>
                {
                    _stream.EndWrite(r);

                    ctx._position += stuff.Length;
                };

                // Put cursor in the right place
                //_stream.Position = ctx._position;
                // TODO Fix this, for now ignore (assume cursor on the right place)

#if DEBUG && !SILVERLIGHT
                MultiTasksRuntime.DebugDisplayInfo();
#endif
                _stream.BeginWrite(stuff, 0, stuff.Length, wroteCallback, null);
            }
            catch (Exception e)
            {
                throw new Exception("Exception on Stream.write", e);
            }
        }
Exemplo n.º 2
0
 public MtStreamWritingContext CreateWritingContext()
 {
     if (!_stream.CanWrite)
     {
         throw new Exception("You can't write in this stream!");
     }
     var w = new MtStreamWritingContext(0);
     return w;
 }
Exemplo n.º 3
0
        public MtStreamWritingContext CreateWritingContext()
        {
            if (!_stream.CanWrite)
            {
                throw new Exception("You can't write in this stream!");
            }
            var w = new MtStreamWritingContext(0);

            return(w);
        }
Exemplo n.º 4
0
        public void Write(MtStreamWritingContext ctx, byte[] stuff, Action doneCallback)
        {
            #if DEBUG && !SILVERLIGHT
            Debug.Print("Write");
            #endif

            try
            {
                AsyncCallback wroteCallback = null;
                wroteCallback = r =>
                {
                    _stream.EndWrite(r);

                    ctx._position += stuff.Length;

                    doneCallback();
                };

                // Put cursor in the right place
                _stream.Position = ctx._position;

            #if DEBUG && !SILVERLIGHT
                MultiTasksRuntime.DebugDisplayInfo();
            #endif
                _stream.BeginWrite(stuff, 0, stuff.Length, wroteCallback, null);
            }
            catch (Exception e)
            {
                throw new Exception("Exception on Stream.write", e);
            }
        }