private void ReceiveCallback()
{
// Receive packet
currentReceive = client.ReceiveAsync();
currentReceive.ContinueWith((task) =>
{
if (!task.IsCanceled && !task.IsFaulted)
{
var data = task.Result.Buffer;
// Write the packet to the audio stream
audioStream.Write(data, 0, data.Length);
if (listening)
{
ReceiveCallback();
}
}
});
}