Cosmos/source2/VSIP/Cosmos.VS.Debug/MainWindow.xaml.cs
kudzu_cp 39d7b7dbdf
2011-06-26 04:45:55 +00:00

62 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
namespace Cosmos.VS.Debug
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
PipeThread.DataPacketReceived += new Action<byte, byte[]>(PipeThread_DataPacketReceived);
var xServerThread = new Thread(PipeThread.ThreadStartServer);
xServerThread.Start();
Thread.Sleep(1000);
var xPipe = new NamedPipeClientStream(".", "CosmosDebugWindows", PipeDirection.Out);
xPipe.Connect(100);
}
void PipeThread_DataPacketReceived(byte aCommand, byte[] aMsg)
{
// Assembly
if ((int)aCommand == 3)
{
if (asmUC1.listBox1.Dispatcher.CheckAccess())
{
string xData = Encoding.ASCII.GetString(aMsg);
asmUC1.listBox1.Items.Add(xData);
}
else
{
asmUC1.listBox1.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate()
{
string xData = Encoding.ASCII.GetString(aMsg);
asmUC1.listBox1.Items.Add(xData);
});
}
}
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
PipeThread.Stop();
}
}
}