1、
.net4新特性 1.SpinLock.2.ManualResetEventSlim.两者有一个共同点,即都采用cpu空转的方式“在线等待通知”,以减少线程上下文切换带来的性能损失。
2.
1、
post-build event command
can not find *.exe--因为字符编码的问题,导致路径出现乱码,所以找不到路径。
The command "..." exited with code 1104
2、exited with code -1073741515. change to hex:C0000135,some dll/compent is missing.
vsvars32.bat--设置环境变量
I found that some enviroment variables need to be set, and also, since I was having trouble propogating my newly configured executables to the install project, I had to modify the target to both the bin/release folder and the obj/release folders. Here is the command build events that finally work:
call "$(DevEnvDir)..\tools\vsvars32.bat" 如果文件夹带有空格,需加“”;C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools\vsvars32.bat
editbin.exe /STACK:2000000 /LARGEADDRESSAWARE "$(TargetPath)"
editbin.exe /STACK:2000000 /LARGEADDRESSAWARE "$(ProjectDir)obj\$(ConfigurationName)\$(TargetFileName)"
pa—aa:中间的短杠是在中文状态下打出来的。作为命令执行且操作系统的字符集是英文,短杠会变成乱码。所以最好不要这么去命名文件夹的名字。
vsvars32.bat--"C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools" 设置vs有关的环境变量
editbin.exe,dumpbin.exe--C:\Program Files\Microsoft Visual Studio 10.0\VC\bin
dumpbin.exe /headers *.exe ,查看stack size:1C9C380(hex,单位bit) size of stack reserve
editbin.exe /stack:20000000 *.exe
cmd:1.设置成可以快速编辑。2.在其他文本复制,在cmd中点击右键,即可粘帖。3.选中cmd内容,按ctrl+enter复制,点击右键在需要的地方粘帖。4.可设置codepage:437和936
3.
.net事件的参数,如DoWorkEventArgs,把多个参数封装成一个class的思想。
4.
static MyClass(){...}//can not have access modifier
public MyClass(){...}
MyClass mc = new MyClass();//first invoke static constructor,then invoke instance constructor.
5
vs2010 中文乱码
//0†30Š90‡60„3BackgroundWorker¡Á¨¦0†40‹60…80‡20ˆ60‹50ˆ70‡1
BackgroundWorker bw=sender asBackgroundWorker;
http://www.dotblogs.com.tw/yc421206/archive/2011/06/09/27596.aspx
0521
http://www.microsoft.com/china/msdn/events/webcasts/shared/webcast/Series/WP.aspx
http://blog.csdn.net/cc_net/article/details/6552867
6.
0522
枚举加[Flags],可用 | 组合(或运算),用&判断是否存在某个值。0x1,0x2,0x4,0x8
0528
wcf通道的理解,底层是socket连接,server端等待client的连接,然后返回一个socket。
0609
委托类内部有3个private field:_target,_methodPtr,_prev(指向另一个委托对象,即委托链)。重写了Equals方法比较这三个字段是否匹配。
0709
stringbuilder sb = new stringbuilder(2048);
for(int i =0;i<list.count;i++)
{
if(i == (list.count-1))
{
sb.Append(list[i]);
continue();//进入下一个循环
}
sb.AppendLine(list[i]);
}
I/0操作比较费时。尽量减少I/O操作。
0727
1、SynchronizationContext sc = Synchronization.Current.//与当前线程绑定,获取当前线程上下文。
SendOrPostCallback callback = (p)=>{ ....};
sc.Post(callback,null);
2、MidPointRound.AwayFromZero(当后一位是5时,进到远离0的数。2.5-->3),ToEven(当后一位是5时,进到偶数.2.5-->2)。
3.
(using(MemoryStream ms = new MemoryStream()))
{
Byte[] b = new Byte[ms.Length];
ms.Seek(0,SeekOrigin.Begin);
int count = ms.Read(b,0,b.Length);// The new position within the stream,
string s = Encoding.ASCII.GetString(b);
}
4、加载资源文件
using(Stream s = this.GetType().Assembly.GetManifestResourceStream(""))
{
}
5、