private void btnSend_Click(object sender, EventArgs e) { var message = tbMessage.Text; if (string.IsNullOrWhiteSpace(message)) { MessageBox.Show(this, "Сообщение не должно быть пустым.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } var machine = tbServerName.Text; if (string.IsNullOrWhiteSpace(machine)) { MessageBox.Show(this, "Необходимо указать имя компьютера, на который будет отправлено сообщение.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } var client = new MailslotClient(ServerName, machine); client.SendMessage(message); }
static void Main(string[] args) { using (var client = new MailslotClient("LagomLitenLedMailSlot")) { try { if (args.Length != 0) { client.SendMessage(String.Join(",",args)); } else // no arguments { throw new Exception("Nothing to do."); } } catch (Exception ex) { Console.WriteLine(); Console.WriteLine(ex.Message); Console.ReadKey(); } finally { } } }
public Form1() { InitializeComponent(); AddLog(SginatureError.INFO, "Приложение запущено"); _mailslotServer = new MailslotServer(); _mailslotClient = new MailslotClient(); }
public void RoundTrip() { using (var server = new MailslotServer("round_trip")) { using (var client = new MailslotClient("round_trip")) { for (var i = 0; i < 10; i++) { var msg = $"Message {i}"; client.SendMessage(msg); var read = server.GetNextMessage(); Assert.AreEqual(msg, read); } } } }
static void Main(string[] args) { MailslotClient client = new MailslotClient("test"); client.Connect(); try { for (int i = 1; i <= 256; i++) { byte[] buffer = Encoding.UTF8.GetBytes("Iteration " + i.ToString()); int count = client.Write(buffer); Thread.Sleep(1000); } } finally { client.Disconnect(); } }
private void HandleKey(KeyboardHookEventArgs e) { if (e.KeyboardEventName == KeyboardEventNames.KeyUp || e.KeyboardEventName == KeyboardEventNames.KeyDown) { // check if the key is mapped ( LEDBlinkyInputMap.xml is parsed into KeyCodes[] already ) int index = Array.IndexOf(KeyCodes, ((WindowsVirtualKey)e.VirtualKeyCode).ToString()); if ( index >= 0) { using (var client = new MailslotClient("LagomLitenLedMailSlot")) { // change so it tries to send, if server is down it will fail as it is now client.SendMessage(index + "," + e.KeyboardEventName.ToString() ); } } } }