摘要: 拦截异常并用企业库处理:private void AttachUnhandledException() { //这个异常一样要加,否则如果后台线程发生异常,DispatherUnhandledException是扑捉不到的。 AppDomain.CurrentDomain.UnhandledException += (sender, args) => { Exception ex = new Exception(String.Format(LanguageReader.GetValue("Applic... 阅读全文
posted @ 2010-01-23 22:10 primeli 阅读(978) 评论(0) 推荐(0) 编辑
摘要: 谜底很简单,把你的程序的进程优先级从普通设置成高即可,这样OS会多分配CPU时间来运行你的程序,这样就快了。呵呵static App() { Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; Process.GetCurrentProcess().PriorityBoostEnabled = true; } 阅读全文
posted @ 2010-01-23 21:59 primeli 阅读(301) 评论(0) 推荐(0) 编辑
摘要: 支持多语言的核心无非是,切换Applicaion级别的ResourceDictionary语言文件随意编辑,无非是在程序启动时,加载一下某个资源文件而已。为了支持界面使用多语言,我们自己定义了一个Resource扩展标记。同时,为了防止,用户误将语言资源删除,而引起界面无任何文字的情况,我们内部定义了一个默认的资源文件,这样就不会没有显示了。资源文件的目录结构:Languages目录下有Default.xaml, en-US.xaml, zh-CN.xaml等先上核心读取类LanguageReader:#region Header/** * <pre> * * Work Force 阅读全文
posted @ 2010-01-23 21:55 primeli 阅读(559) 评论(0) 推荐(0) 编辑
摘要: public interface ITransaction : IDisposable { bool IsActive { get; } bool WasCommitted { get; } bool WasRolledBack { get; } void Begin(); void Begin(IsolationLevel isolationLevel); void Commit(); void Enlist(IDbCommand command); void Regist... 阅读全文
posted @ 2010-01-23 21:41 primeli 阅读(528) 评论(0) 推荐(0) 编辑
摘要: public class WeakLazy<T> : IDisposable { private readonly WeakReference _weakReference; private T _instance; private Func<T> _valueFactory; private readonly bool _isWeak; private readonly bool _isThreadSafe; private readonly object _lockObj; public... 阅读全文
posted @ 2010-01-23 21:27 primeli 阅读(423) 评论(0) 推荐(0) 编辑
摘要: 1. 获取数组倒数N个public static IEnumerable<T> GetFromEnd<T>(this T[] array, int count) { for (int i = array.Length - 1; i > array.Length - 1 - count; i--) { yield return array[i]; } }2. Foreach集合,连续做事情。public static IEnumerable<T> ForEach<T>(th... 阅读全文
posted @ 2010-01-23 21:17 primeli 阅读(281) 评论(0) 推荐(0) 编辑