活到老学到老

现学现卖

博客园 首页 新随笔 联系 订阅 管理

2008年11月30日 #

摘要: c++/cli的根本意义在于互操作的语言集成和编写不安全代码的能力。我觉得实际上很少有c++/cli可以做但是c#作不到的事。c#也可以很愉快地编写不安全代码和p/invoke,或者CRW。但是c#做这些事确实要比c++/cli费劲得多。 另外,c++/cli还可以使用宏和stl。 阅读全文
posted @ 2008-11-30 11:28 John Rambo 阅读(196) 评论(1) 推荐(0) 编辑

2008年11月27日 #

摘要: 知道double-checked locking的时候应该使用volatile,但是没有仔细想过为什么。今天想起这个问题,费解了一上午,现在终于想到一个解释。 //broken double-checked locking Code Code highlighting produced by Act... 阅读全文
posted @ 2008-11-27 13:10 John Rambo 阅读(405) 评论(0) 推荐(0) 编辑

2008年11月18日 #

摘要: Code Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->usingSystem; usingSystem.Collections.Generic; u... 阅读全文
posted @ 2008-11-18 18:21 John Rambo 阅读(233) 评论(0) 推荐(0) 编辑

摘要: 兼容模式 read upgradable write read true true false upgradable truefalse false write false falsefalse 这个矩阵是对称的。read-> upgradable-> write 锁定级别依次提高。 所谓的锁定... 阅读全文
posted @ 2008-11-18 14:24 John Rambo 阅读(514) 评论(0) 推荐(0) 编辑

摘要: System.Runtime.Remoting.Messaging.CallContext类 MSDN: CallContext is a specialized collection object similar to a Thread Local Storage for method call... 阅读全文
posted @ 2008-11-18 13:16 John Rambo 阅读(3144) 评论(1) 推荐(3) 编辑

2008年11月16日 #

摘要: Cause I just figured out this, GDI+ is not for video games... 我真是太弱了。居然现在才想到这一点。GDI+基本上只是GDI的简单封装,而GDI是用于绘制Window本身UI的API。GDI没有使用任何硬件加速功能,所有的绘图操作由cpu实... 阅读全文
posted @ 2008-11-16 23:59 John Rambo 阅读(268) 评论(0) 推荐(0) 编辑

摘要: Windows forms中自带的Timer控件据说精度只有55ms。又有传说在Winnt 4.0以上精度可以达到10ms。 不知道为什么已经没有心情再去考证到底是怎么回事,决定自己写一个: Code Code highlighting produced by Actipro CodeHighli... 阅读全文
posted @ 2008-11-16 18:26 John Rambo 阅读(157) 评论(0) 推荐(0) 编辑

2008年11月11日 #

摘要: 代码 建立一个解决方案,里面添加2个类库项目FirstPSPlugin和FirstPlugin.Task。 一般一个Postsharp由两个部分构成,FirstPSPlugin这个程序集中定义一系列Custom Attributes,用于标记将要被 处理的语言元素。例如可以标记一个OnExcepti... 阅读全文
posted @ 2008-11-11 15:17 John Rambo 阅读(2248) 评论(0) 推荐(0) 编辑

2008年11月7日 #

摘要: 以前看C# specification时见过这两个字,一直不知道什么意思,没想到是System命名空间下的一个类。 这个类的实例能够持有一个对象的引用但是这个对象却仍然能够被gc回收。其实msdn上已经说的很明白了,为什么我还要在这里废话?空虚? 通过构造函数可以构造两类弱引用实例,称为长弱引用和短... 阅读全文
posted @ 2008-11-07 23:00 John Rambo 阅读(588) 评论(1) 推荐(0) 编辑

摘要: 今天发现了这个很酷的东西,可以用来标记静态字段。就我的理解,被标记为ThreadStaticAttribute的静态字段的语义将会变化,从一个正常的内存地址变成TLS中的一个存储位置。就当它做访问TLS的一种快捷方式。不同的ThreadStatic静态字段并不会冲突,表示TLS中独立的存储位置。 网... 阅读全文
posted @ 2008-11-07 21:54 John Rambo 阅读(636) 评论(0) 推荐(0) 编辑