Many people look at the Interlocked methods and wonder why Microsoft doesn't create a richer set of interlocked methods that can be used in a wider range of scenarios. For example, it would be nice if the Interlocked class offered Multiply, Divide, M…
设计模式:空对象模式(Null Object Pattern) 背景 群里聊到<ASP.NET设计模式>,这本书里有一个“Null Object Pattern”,大家就闲聊了一下这个模式,在此记录一下大概的结论. 典型结构 模式的结构非常简单,这里就不多说了,类图如下: 为什么使用这个模式?还需要null吗? 之所以需要这个模式是因为这个模式可以消除重复.想象一下,假如有多个消费端,每个消费端都要判断一下是否为空,而且对于为空的场景要做特殊的处理,这样就会导致很多重复.一些例子是:日志对象和…
本系列文章来自 CLR VIA C# .NET FrameWork在Microsoft  Windows平台的顶部运行.这意味着.NET必须用Windows可以理解的技术来构建.首先,所有的托管模块和程序集文件都必须使用Windows PE文件格式,而且要么是一个Windows.exe文件,要么是一个DLL文件. 开发CLR时,Microsoft实际是将它实现成包含在一个DLL中的COM服务器.也就是说,Microsoft为CLR定义了一个标志的COM接口,并为该接口和COM服务器分配了GUID…
错误内容: 微软的错误说明:http://support.microsoft.com/kb/2640103/zh-cn 类似下面的错误: 错误应用程序名称:xxx.exe,版本: 1.0.0.0,时间戳: 0x4f151376 错误模块名称: clr.dll,版本: 4.0.30319.17929,时间戳: 0x4ffa5753 异常代码: 0xc0000005 错误偏移量: 0x0017cbb0 错误进程 ID: 0x11b0 错误应用程序启动时间: 0x01ce21289ba21023 错误…
CLR(Common Language Runtime)公共语言进行时是一个可由多种编程语言使用的“进行时”. 将源代码编译成托管模块 可用支持CLR的任何语言创建源代码文件,然后用对应的编译器检查语法和分析源代码.无论选择哪个编译器,结果都是托管模块(managed module).托管模块是标准的32位Microsoft Windows可移植执行体(PE32)文件,或者是标准的64位Windows可移植执行体(PE32+)文件,他们都需要CLR才能执行.(注:PE是Portable Exec…
The CLR guarantees that reads and writes to variables of the following data types are atomic: Boolean, Char, (S)Byte, (U)Int16, (U)Int32, (U)IntPtr, Single, and reference types. This means that all bytes within that variable are read from or written…
User-Mode Constructs The CLR guarantees that reads and writes to variables of the following data types are atomic: Boolean, Char, (S)Byte, (U)Int16, (U)Int32, (U)IntPtr, Single, and reference types. This means that all bytes within that variable are…
线程槽 使用线程池了以后就不要使用线程槽了,当线程池执行完调度任务后,线程槽的数据还在. 测试代码 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Runtime.Remoting; namespace ExecutionContextStu…
The CLR’s Execution Model The core features of the CLR memory management. assembly loading. security. exception handling. thread synchronization. Managed Module Parts of a Managed Module: PE32 or PE32+ header:The standard Windows PE file header, whic…
在学习.NET的时候,因为一些疑问,让我打算把.NET的类型篇做一个总结.总结以三篇博文的形式呈现. 这篇博文,作为三篇博文的第一篇,主要探讨了.NET Framework中的基本类型,以及这些类型一些重要的特性. 第二篇中,我会探讨.NET 是如何实现两个对象的比较的,其中会用到第一篇中的基础和结论. 第三篇,我从CLR中的常用容器出发,来探讨泛型以及它们背后的数据结构. 下面,我们从类型说起. Primitive, Reference and Value 首先将这三种类型放在一起是不科学的.…