src/UWP.Samples.AsyncResponseFromSerialDevice/PackageManager.cs
/// <summary>
/// Sends a request to serial device.
/// </summary>
Sends a request to serial device.
Sends a request to serial device .
public async Task<byte[]> SendAsync(byte[] data)
        {
            var package = new RequestPackage();
            package.Data = data;
            package.Id = this.packageCounter++;
            var sendCompletionSource = new TaskCompletionSource<byte[]>();
            this.waitingForResponse.Add(package.Id, sendCompletionSource);
            dataWriter.WriteBytes(package.GetBytes());
            await dataWriter.StoreAsync();
            return await sendCompletionSource.Task;
        }
public async Task < byte [ ] > SendAsync ( byte [ ] data ) { var package = new RequestPackage ( ) ; package . Data = data ; package . Id = this . packageCounter ++ ; var sendCompletionSource = new TaskCompletionSource < byte [ ] > ( ) ; this . waitingForResponse . Add ( package . Id , sendCompletionSource ) ; dataWriter . WriteBytes ( package . GetBytes ( ) ) ; await dataWriter . StoreAsync ( ) ; return await sendCompletionSource . Task ; }
Sends a request to serial device.
Sends a request to serial device .
data
byte[]