|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WindowsPipes;
using System.Threading;
namespace PipeClient
{
public partial class ClientForm : Form
{
private ManagedPipe _pipe;
private Thread _receiveThread;
public ClientForm()
{
InitializeComponent();
_pipe = new ManagedPipe("Test1", ManagedPipeType.Client,
BlockingMode.Wait, 1024, 1024);
}
private void ClientForm_Load(object sender, EventArgs e)
{
_pipe.Open();
_receiveThread = new Thread(new ThreadStart(ReceiveThreadFunction));
_receiveThread.IsBackground = true;
_receiveThread.Start();
}
private void ReceiveThreadFunction()
{
while (true)
{
string message = _pipe.Receive();
if (message == null)
return;
txtReceiveMessage.Invoke((MethodInvoker)delegate()
{
txtReceiveMessage.Text += message + "\r\n";
});
}
}
private void btnSend_Click(object sender, EventArgs e)
{
_pipe.Send(txtSendMessage.Text);
txtSendMessage.Text = string.Empty;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Nothing to brag about, just another passionate software developer.
Work to make a living, don't live to work!