/// <summary> /// Queues up a data buffer to send over the network. /// </summary> /// <param name="dataBufferToSend">The data buffer to send.</param> /// <summary> /// Sends the data over the network. /// </summary> /// <param name="dataBufferToSend">The data buffer to send.</param> private void SendDataOverNetwork(byte[] dataBufferToSend) { if (Sending) { // This shouldn't happen, but just in case. Debug.Log("one at a time please"); return; } if (networkConnection == null) { Debug.Log("Network connection not yet initialized"); return; } // Track that we are sending a data buffer. Sending = true; nextDataBufferToSend = dataBufferToSend; IAsyncOperationWithProgress <uint, uint> newmessagereceived = networkConnection.OutputStream.WriteAsync(nextDataBufferToSend.AsBuffer()); AsyncOperationWithProgressCompletedHandler <uint, uint> aowpch = new AsyncOperationWithProgressCompletedHandler <uint, uint>(DataSentHandler); newmessagereceived.Completed = aowpch; }
public static void TrackAsyncAction <T, TProgress>(IAsyncOperationWithProgress <T, TProgress> action, Func <TProgress, double> progressConverter, AsyncOperationWithProgressCompletedHandler <T, TProgress> completed) { DisableView(null); action.Completed = (s, e) => root.Dispatcher.Begin(() => { EnableView(); completed(s, e); }); action.Progress = (s, p) => root.Dispatcher.Begin(() => DisableView(progressConverter(p))); }
public static void TrackAsyncAction <T>(IAsyncOperationWithProgress <T, double> action, AsyncOperationWithProgressCompletedHandler <T, double> completed) { TrackAsyncAction(action, p => p, completed); }
internal override void OnCompleted(AsyncOperationWithProgressCompletedHandler <TResult, TProgress> userCompletionHandler, AsyncStatus asyncStatus) { Debug.Assert(userCompletionHandler != null); userCompletionHandler(this, asyncStatus); }