Final change for new release.

This commit is contained in:
EdwardNutting_cp 2013-12-24 18:05:49 +00:00
parent a952b8ff4b
commit 33fd366580

View file

@ -140,56 +140,56 @@ namespace Cosmos.Debug.Common
#endif
}
protected void DoRead(IAsyncResult aResult)
{
try
{
var xIncoming = (Incoming)aResult.AsyncState;
int xCount = xIncoming.Stream.EndRead(aResult);
// protected void DoRead(IAsyncResult aResult)
// {
// try
// {
// var xIncoming = (Incoming)aResult.AsyncState;
// int xCount = xIncoming.Stream.EndRead(aResult);
System.Diagnostics.Debug.WriteLine(String.Format("DC - Received: {0}", BytesToString(xIncoming.Packet, xIncoming.CurrentPos, xCount)));
xIncoming.CurrentPos += xCount;
if (xCount == 0)
{
// If 0, end of stream then just exit without calling BeginRead again
return;
}
else if (xIncoming.CurrentPos < xIncoming.Packet.Length)
{
// Packet is not full yet, read more data
#if TRACK_PENDING
try {
Interlocked.Increment(ref _pendingReadsCount);
#endif
xIncoming.Stream.BeginRead(xIncoming.Packet, xIncoming.CurrentPos
, xIncoming.Packet.Length - xIncoming.CurrentPos
, new AsyncCallback(DoRead), xIncoming);
#if TRACK_PENDING
}
catch (Exception e) {
Interlocked.Decrement(ref _pendingReadsCount);
throw;
}
#endif
}
else
{
System.Diagnostics.Debug.WriteLine(String.Format("DC - Full packet received - Received: {0}", BytesToString(xIncoming.Packet, 0, xIncoming.Packet.Length)));
// System.Diagnostics.Debug.WriteLine(String.Format("DC - Received: {0}", BytesToString(xIncoming.Packet, xIncoming.CurrentPos, xCount)));
// xIncoming.CurrentPos += xCount;
// if (xCount == 0)
// {
// // If 0, end of stream then just exit without calling BeginRead again
// return;
// }
// else if (xIncoming.CurrentPos < xIncoming.Packet.Length)
// {
// // Packet is not full yet, read more data
//#if TRACK_PENDING
// try {
// Interlocked.Increment(ref _pendingReadsCount);
//#endif
// xIncoming.Stream.BeginRead(xIncoming.Packet, xIncoming.CurrentPos
// , xIncoming.Packet.Length - xIncoming.CurrentPos
// , new AsyncCallback(DoRead), xIncoming);
//#if TRACK_PENDING
// }
// catch (Exception e) {
// Interlocked.Decrement(ref _pendingReadsCount);
// throw;
// }
//#endif
// }
// else
// {
// System.Diagnostics.Debug.WriteLine(String.Format("DC - Full packet received - Received: {0}", BytesToString(xIncoming.Packet, 0, xIncoming.Packet.Length)));
// Full packet received, process it
xIncoming.Completed(xIncoming.Packet);
}
}
catch (System.IO.IOException ex)
{
ConnectionLost(ex);
}
#if TRACK_PENDING
finally {
Interlocked.Decrement(ref _pendingReadsCount);
}
#endif
}
// // Full packet received, process it
// xIncoming.Completed(xIncoming.Packet);
// }
// }
// catch (System.IO.IOException ex)
// {
// ConnectionLost(ex);
// }
//#if TRACK_PENDING
// finally {
// Interlocked.Decrement(ref _pendingReadsCount);
// }
//#endif
// }
private List<Incoming> ReadQueue = new List<Incoming>();
private bool reading = false;
@ -215,11 +215,11 @@ namespace Cosmos.Debug.Common
}
else
{
mStream.BeginRead(next.Packet, next.CurrentPos, next.Packet.Length - next.CurrentPos, new AsyncCallback(DoRead2), next);
mStream.BeginRead(next.Packet, next.CurrentPos, next.Packet.Length - next.CurrentPos, new AsyncCallback(DoRead), next);
}
}
}
private void DoRead2(IAsyncResult result)
private void DoRead(IAsyncResult result)
{
try
{