摘要: 一. 子线程的数据,赋给主线程的控件1.实例化线程//消息线程Thread receiveThread = new Thread(new ThreadStart(ReceiveMessageThread));//ReceiveMessageThread为线程的回调方法receiveThread.IsBackground = true; //设置线程为后台线程.(设置成后台线程后,前台主线程关闭,则此后台线程将强制关闭)receiveThread.Start(); //启动线程2. 线程回调方法//定义委托,用于后台线程与主线程的数据交互public delegate void FuncHand 阅读全文
posted @ 2012-12-26 14:58 LiGang 阅读(1902) 评论(0) 推荐(0) 编辑
摘要: 在窗体加载时,注册以下事件 this.MainTabControl.DrawMode = TabDrawMode.OwnerDrawFixed; this.MainTabControl.Padding = new System.Drawing.Point(CLOSE_SIZE, 5); this.MainTabControl.DrawItem += new DrawItemEventHandler(this.MainTabControl_DrawItem); this.MainTabControl.MouseDown += new System.Windows.Forms.Mouse... 阅读全文
posted @ 2012-12-26 14:44 LiGang 阅读(2049) 评论(0) 推荐(0) 编辑
摘要: public partial class UserMessageControl : UserControl { public UserMessageControl() { InitializeComponent(); //为防止由控件重绘引起的闪烁,我们可以启用双缓冲,指定控件的ControlStyles.DoubleBuffer为true。 //要完全启用双缓冲,必须也要将 UserPaint 和 AllPaintingInWmPaint位数设置为 true this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(Contro. 阅读全文
posted @ 2012-12-26 14:38 LiGang 阅读(384) 评论(0) 推荐(0) 编辑
摘要: 客户端进行异步操作接收信息及发送信息分开进行,运行多线程进行管理主要代码发下:using System;using System.Collections.Generic;using System.Text;using System.Net.Sockets;using System.Threading;using System.Net;// 实现Socket客户端的连接通信逻辑。 internal sealed class SocketClient : IDisposable { // Socket操作常数。 private const Int32 ReceiveOperation = 1, S 阅读全文
posted @ 2012-12-26 14:29 LiGang 阅读(384) 评论(0) 推荐(0) 编辑
摘要: 运用 SocketAsyncEventArgs 进行异步操作服务端三个类第一个类: SocketAsyncEventArgsPoolinternal sealed class SocketAsyncEventArgsPool { /// <summary> /// Pool of SocketAsyncEventArgs. /// </summary> Stack<SocketAsyncEventArgs> pool; /// <summary> /// Initializes the object pool to the specified s 阅读全文
posted @ 2012-12-26 14:21 LiGang 阅读(571) 评论(0) 推荐(0) 编辑
摘要: Socket 初步操作1.客户端public void FirstMain(string[] args) { byte[] data = new byte[1024]; //实例化socket对象 Socket newclient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); //设置远程服务器的IP及端口 Console.WriteLine("please input the server ip: "); string ipadd = Console.ReadL 阅读全文
posted @ 2012-12-26 13:57 LiGang 阅读(232) 评论(0) 推荐(0) 编辑