随笔分类 -  C# 代码笔记

摘要:STAThread:singlethreadedapartment 直译过来是:单线程单元套间MTAThread:multiple threaded apartment 直译过来是:多线程单元套间差别其实就是这个:其他线程对STA中的COM对象的访问需要列集(marshal),通过列集,自动实现了多线程访问下的同步。所有线程对MTA中的COM对象的访问不需要列集,直接访问,需要COM组件自身实现多线程下的同步。COM对象和客户端的组件模型设定, 决定最终的组件模型时怎样, 以下这篇文章挺详细:http://www.cnblogs.com/ioexception/p/dotnet_STAThre 阅读全文
posted @ 2013-08-08 10:45 Thyiad 阅读(925) 评论(0) 推荐(0)
摘要:需要用到MemoryFailPoint:using(MemoryFailPoint mfp=new MemoryFailPoint(1500)){ //Do using many memory account}catch(InsufficientMemoryException e){ throw e ;} 阅读全文
posted @ 2013-08-08 10:02 Thyiad 阅读(191) 评论(0) 推荐(0)
摘要://获取程序的基目录。System.AppDomain.CurrentDomain.BaseDirectory//获取模块的完整路径。System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName//获取和设置当前目录(该进程从中启动的目录)的完全限定目录。System.Environment.CurrentDirectory//获取应用程序的当前工作目录。System.IO.Directory.GetCurrentDirectory()//获取和设置包括该应用程序的目录的名称。System.AppDomain.Curren 阅读全文
posted @ 2013-08-08 10:00 Thyiad 阅读(193) 评论(0) 推荐(0)
摘要:.netFramework4.0中对读取64位注册表做了支持,只需要一个RegistryView:RegistryKey localMachine = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64); 阅读全文
posted @ 2013-08-08 09:56 Thyiad 阅读(175) 评论(0) 推荐(0)
摘要:RT,不赘述,代码以下: 1 const int WM_SYSCOMMAND = 0x112; 2 const int SC_CLOSE = 0xF060; 3 const int SC_MINIMIZE = 0xF020; 4 const int SC_MAXIMIZE = 0xF030; 5 protected override void WndProc(ref Message m) 6 { 7 if (m.Msg == WM_SYSCOMMAND) 8 { 9 if (m.WParam.ToInt32() == SC_MINIMIZE) 10 ... 阅读全文
posted @ 2013-08-08 09:27 Thyiad 阅读(250) 评论(0) 推荐(0)
摘要:之前在做一个任务时, 需要比较字符串的相似度, 最终整理了一个出来, 以下: 1 /* 2 * Copyright (c) 2013 Thyiad 3 * Author: Thyiad 4 * Create date: 2013/08/08 5 */ 6 7 using System; 8 9 namespace Thyiad.Utility 10 { 11 /// 12 /// Operates about string. 13 /// 14 public static class StringUtil 15 { 16... 阅读全文
posted @ 2013-08-08 09:15 Thyiad 阅读(271) 评论(0) 推荐(0)