Ejemplo n.º 1
0
        public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
        {
            StorageAsyncResult <NullType> result = new StorageAsyncResult <NullType>(callback, state);

            if (this.completeSynchronously)
            {
                result.UpdateCompletedSynchronously(this.completeSynchronously);
                try
                {
                    this.Write(buffer, offset, count);
                    result.OnComplete();
                }
                catch (Exception e)
                {
                    result.OnComplete(e);
                }
            }
            else
            {
                ThreadPool.QueueUserWorkItem(_ =>
                {
                    result.UpdateCompletedSynchronously(this.completeSynchronously);
                    try
                    {
                        this.Write(buffer, offset, count);
                        result.OnComplete();
                    }
                    catch (Exception e)
                    {
                        result.OnComplete(e);
                    }
                },
                                             null);
            }

            return(result);
        }
Ejemplo n.º 2
0
        public override void EndWrite(IAsyncResult asyncResult)
        {
            StorageAsyncResult <NullType> result = (StorageAsyncResult <NullType>)asyncResult;

            result.End();
        }