12 2012 档案
摘要:一. 子线程的数据,赋给主线程的控件1.实例化线程//消息线程Thread receiveThread = new Thread(new ThreadStart(ReceiveMessageThread));//ReceiveMessageThread为线程的回调方法receiveThread.IsBackground = true; //设置线程为后台线程.(设置成后台线程后,前台主线程关闭,则此后台线程将强制关闭)receiveThread.Start(); //启动线程2. 线程回调方法//定义委托,用于后台线程与主线程的数据交互public delegate void FuncHand
阅读全文
摘要:在窗体加载时,注册以下事件 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...
阅读全文
摘要:public partial class UserMessageControl : UserControl { public UserMessageControl() { InitializeComponent(); //为防止由控件重绘引起的闪烁,我们可以启用双缓冲,指定控件的ControlStyles.DoubleBuffer为true。 //要完全启用双缓冲,必须也要将 UserPaint 和 AllPaintingInWmPaint位数设置为 true this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(Contro.
阅读全文
摘要:客户端进行异步操作接收信息及发送信息分开进行,运行多线程进行管理主要代码发下: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
阅读全文
摘要:运用 SocketAsyncEventArgs 进行异步操作服务端三个类第一个类: SocketAsyncEventArgsPoolinternal sealed class SocketAsyncEventArgsPool { /// <summary> /// Pool of SocketAsyncEventArgs. /// </summary> Stack<SocketAsyncEventArgs> pool; /// <summary> /// Initializes the object pool to the specified s
阅读全文
摘要: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
阅读全文
摘要:先说下改变窗体样式的代码,如下:this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;实现点击winform窗体,运用鼠标就可以移动窗体,而不需要点击窗体边框处。using System.Runtime.InteropServices;在窗体内加上以下代码:[DllImport("user32.dll")] public static extern bool ReleaseCapture(); [DllImport("user32.dll")] public static ext
阅读全文
摘要:XPath语法 在C#中使用XPath示例XPath可以快速定位到Xml中的节点或者属性。XPath语法很简单,但是强大够用,它也是使用xslt的基础知识。示例Xml:<?xml version="1.0" encoding="utf-8" ?> <pets> <cat color="black" weight="10"> <price>100</price> <desc>this is a black cat</desc> <
阅读全文
摘要:实现效果如下:新增文件时的xml如下<?xml version="1.0" encoding="UTF-8"?><Setting> <ServerSetting> <ServerIP>192.168.3.46</ServerIP> <ServerPort Name="端口号">19888</ServerPort> </ServerSetting></Setting>修改文件时的xml结构如下:<?xml version=&
阅读全文
摘要:原文:http://www.uipower.com/bbs/thread-98568-1-1.html今天在做ASP.NET操作XML文档的过程中,发现了两个类:XmlNode和XmlElement。这两个类的功能极其类似(因为我们一般都是在对Element节点进行操作)。上网搜罗了半天,千篇一律的答案。永远说不到重点,有些人回答又特别含糊,无奈之下,自己设断点尝试对比效果,现在总结如下:1、通过继承关系XmlElement继承自XmlLinkedNode又继承自XmlNode类,由此可知XmlElement是XmlNode的子类。我们知道子类继承了父类所有的属性和方法,因此,XmlNode所
阅读全文
摘要:1. ref和out:ref与out是很特殊的两个关键字。使用它们,可以使参数按照引用来传递。ref 关键字使参数按引用传递。其效果是,当控制权传递回调用方法时,在方法中对参数所做的任何更改都将反映在该变量中。若要使用 ref 参数,则方法定义和调用方法都必须显式使用 ref 关键字。out 关键字会导致参数通过引用来传递。这与 ref 关键字类似,不同之处在于 ref 要求变量必须在传递之前进行初始化。若要使用 out 参数,方法定义和调用方法都必须显式使用 out 关键字。区别:out 参数在进入方法(函数)时后清空自己,使自己变成一个干净的参数,也因为这个原因必须在方法返回之前或再使用o
阅读全文
摘要://获取当前进程的完整路径,包含文件名(进程名)。string str = this.GetType().Assembly.Location;result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)//获取新的 Process 组件并将其与当前活动的进程关联的主模块的完整路径,包含文件名(进程名)。string str = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)//
阅读全文
摘要:更新Reporting Server失败TF30225: Error uploading report : Work Item with Tasks解决方案:进入http://localhost/Reports/Pages/Folder.aspx,用管理员账号进入。修改TfsOlapReportDS 和 TfsReportDS的连接方式(单击链接进入),改为:安全存储在报表服务器中的凭据(Credentials stored securely in the report server'),填入访问Reporting Server的用户名和密码,然后选中 在与数据源建立连接时用作 Win
阅读全文

浙公网安备 33010602011771号