12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using DotNettyFrom.common;
- using DotNettyFrom.netty;
-
- namespace DotNettyFrom
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
-
- private NettyClient nc;
- private Thread t;
- private void BtnConnection_Click(object sender, EventArgs e)
- {
- /* var producer = Task.Factory.StartNew(() =>
- {
- for (int count = 0; count < 1000; count++)
- {
-
-
- }
- // blockingCollection.CompleteAdding();
- });*/
- nc = new NettyClient();
- t = new Thread(() => { nc.StartNetty("127.0.0.1", 4001); });
- t.Start();
-
- }
-
- private void Form1_Load(object sender, EventArgs e)
- {
- var consumer = Task.Factory.StartNew(() =>
- {
- foreach (UIInfoModel value in DataModel.ReceCollection.GetConsumingEnumerable())
- {
- Invoke(new ThreadStart(delegate { listBox1.Items.Add(value); }));
- }
- });
- }
-
- private void BtnDisConn_Click(object sender, EventArgs e)
- {
- nc.StopNetty();
- t.Abort();
- }
-
- private void BtnSendData_Click(object sender, EventArgs e)
- {
- nc.SendData("");
- }
- }
- }
|