static void OnGetBufferComplete(IAsyncEventArgs state) { GetBufferEventResult result = ((GetBufferAsyncEventArgs)state).Result; InternalWriteBase64TextAsyncWriter thisPtr = (InternalWriteBase64TextAsyncWriter)state.AsyncState; XmlWriteBase64AsyncArguments writerArgs = thisPtr.writerState.Arguments; Exception completionException = null; bool completeSelf = false; try { if (state.Exception != null) { completionException = state.Exception; completeSelf = true; } else { byte[] chars = result.Buffer; int offset = result.Offset; Base64Encoding encoding = XmlConverter.Base64Encoding; int byteCount = Math.Min(bufferLength / 4 * 3, writerArgs.Count - writerArgs.Count % 3); int charCount = byteCount / 3 * 4; thisPtr.writer.Advance(encoding.GetChars( writerArgs.Buffer, writerArgs.Offset, byteCount, chars, offset)); if (byteCount >= 3) { writerArgs.Offset += byteCount; writerArgs.Count -= byteCount; } if (thisPtr.InternalWriteBase64TextAsync(thisPtr.writerState) == AsyncCompletionResult.Completed) { completeSelf = true; } } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } completionException = exception; completeSelf = true; } if (completeSelf) { thisPtr.writerState.Complete(false, completionException); } }
static void OnFlushComplete(IAsyncEventArgs state) { BufferedOutputAsyncStream thisPtr = (BufferedOutputAsyncStream)state.AsyncState; WriteFlushAsyncEventArgs flushState = (WriteFlushAsyncEventArgs)state; ByteBuffer byteBuffer = flushState.Result; thisPtr.buffers.Enqueue(byteBuffer); }
static void OnWriteComplete(IAsyncEventArgs eventArgs) { InternalWriteBase64TextAsyncWriter thisPtr = (InternalWriteBase64TextAsyncWriter)eventArgs.AsyncState; AsyncEventArgs <XmlNodeWriterWriteBase64TextArgs> state = thisPtr.nodeState; thisPtr.nodeState = null; state.Complete(false, eventArgs.Exception); }
static void GetBufferFlushComplete(IAsyncEventArgs completionState) { XmlStreamNodeWriter thisPtr = (XmlStreamNodeWriter)completionState.AsyncState; GetBufferAsyncEventArgs getBufferState = (GetBufferAsyncEventArgs)thisPtr.flushBufferState.Arguments; getBufferState.Result = getBufferState.Result ?? new GetBufferEventResult(); getBufferState.Result.Buffer = thisPtr.buffer; getBufferState.Result.Offset = 0; getBufferState.Complete(false, completionState.Exception); }
static void OnWriteCallback(IAsyncEventArgs state) { BufferedOutputAsyncStream thisPtr = (BufferedOutputAsyncStream)state.AsyncState; IAsyncResult returnResult = thisPtr.writeState.PendingAsyncResult; AsyncCallback callback = thisPtr.writeState.Arguments.Callback; thisPtr.writeState.Arguments.Callback = null; if (callback != null) { callback(returnResult); } }
static void OnAsyncFlushComplete(IAsyncEventArgs state) { BufferedOutputAsyncStream thisPtr = (BufferedOutputAsyncStream)state.AsyncState; Exception completionException = null; bool completeSelf = false; try { OnFlushComplete(state); if (thisPtr.buffers.TryAcquireLock()) { WriteFlushAsyncEventArgs flushState = (WriteFlushAsyncEventArgs)state; if (flushState.Exception != null) { completeSelf = true; completionException = flushState.Exception; } else { if (thisPtr.WriteAsync(thisPtr.writeState) == AsyncCompletionResult.Completed) { completeSelf = true; } } } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } if (completionException == null) { completionException = exception; } completeSelf = true; } if (completeSelf) { thisPtr.writeState.Complete(false, completionException); } }
static private void OnTrailBytesComplete(IAsyncEventArgs eventArgs) { InternalWriteBase64TextAsyncWriter thisPtr = (InternalWriteBase64TextAsyncWriter)eventArgs.AsyncState; Exception completionException = null; bool completeSelf = false; try { if (eventArgs.Exception != null) { completionException = eventArgs.Exception; completeSelf = true; } else if (thisPtr.WriteBufferAsync() == AsyncCompletionResult.Completed) { completeSelf = true; } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } completionException = exception; completeSelf = true; } if (completeSelf) { AsyncEventArgs <XmlNodeWriterWriteBase64TextArgs> state = thisPtr.nodeState; thisPtr.nodeState = null; state.Complete(false, eventArgs.Exception); } }
static void OnWriteComplete(IAsyncEventArgs eventArgs) { InternalWriteBase64TextAsyncWriter thisPtr = (InternalWriteBase64TextAsyncWriter)eventArgs.AsyncState; AsyncEventArgs<XmlNodeWriterWriteBase64TextArgs> state = thisPtr.nodeState; thisPtr.nodeState = null; state.Complete(false, eventArgs.Exception); }
static private void OnTrailBytesComplete(IAsyncEventArgs eventArgs) { InternalWriteBase64TextAsyncWriter thisPtr = (InternalWriteBase64TextAsyncWriter)eventArgs.AsyncState; Exception completionException = null; bool completeSelf = false; try { if (eventArgs.Exception != null) { completionException = eventArgs.Exception; completeSelf = true; } else if (thisPtr.WriteBufferAsync() == AsyncCompletionResult.Completed) { completeSelf = true; } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } completionException = exception; completeSelf = true; } if (completeSelf) { AsyncEventArgs<XmlNodeWriterWriteBase64TextArgs> state = thisPtr.nodeState; thisPtr.nodeState = null; state.Complete(false, eventArgs.Exception); } }
static void OnWriteComplete(IAsyncEventArgs asyncState) { WriteValueFastAsyncResult thisPtr = (WriteValueFastAsyncResult)asyncState.AsyncState; Exception completionException = null; bool success = false; try { if (asyncState.Exception != null) { completionException = asyncState.Exception; } else { thisPtr.HandleWriteComplete(); success = true; } } catch (Exception ex) { if (Fx.IsFatal(ex)) { throw; } completionException = ex; } if (!success) { thisPtr.nextOperation = Operation.Complete; } thisPtr.ContinueWork(false, completionException); }
static void OnWriteComplete(IAsyncEventArgs asyncEventArgs) { bool completeSelf = false; Exception completionException = null; XmlBaseWriterNodeWriterAsyncHelper thisPtr = (XmlBaseWriterNodeWriterAsyncHelper)asyncEventArgs.AsyncState; AsyncEventArgs<XmlWriteBase64AsyncArguments> inputState = thisPtr.inputState; try { if (asyncEventArgs.Exception != null) { completionException = asyncEventArgs.Exception; completeSelf = true; } else { completeSelf = thisPtr.HandleWriteBase64Text(true); } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } completionException = exception; completeSelf = true; } if (completeSelf) { thisPtr.Clear(); inputState.Complete(false, completionException); } }