Cosmos/source2/Debug/Cosmos.Debug.Common/DebugConnectorPipeServer.cs
kudzu_cp cfb4e0a35f
2011-07-09 21:55:46 +00:00

34 lines
No EOL
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Text;
using System.Threading;
namespace Cosmos.Debug.Common
{
/// Used for Vmware. VMWare uses a pipe to expose guest serial ports to the host.
public class DebugConnectorPipeServer : DebugConnectorStream {
public DebugConnectorPipeServer() {
mPipe = new NamedPipeServerStream("CosmosDebug", PipeDirection.InOut, 1
, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
mPipe.BeginWaitForConnection(new AsyncCallback(DoWaitForConnection), mPipe);
}
private AutoResetEvent mWaitConnectEvent = new AutoResetEvent(false);
private NamedPipeServerStream mPipe;
public void DoWaitForConnection(IAsyncResult aResult) {
var xPipe = (NamedPipeServerStream)aResult.AsyncState;
xPipe.EndWaitForConnection(aResult);
mWaitConnectEvent.Set();
Start(xPipe);
}
public override void WaitConnect() {
mWaitConnectEvent.WaitOne();
}
}
}