代码改变世界

Parallel World 3 – Parallel Loop (3)

2011-06-03 09:38 by wildboar, 538 阅读, 0 推荐, 收藏, 编辑
摘要:I. 设置Parallel Loop选项我们可以为Parallel Loop设置一个ParallelOptions类的实例来影响Parallel Loop的行为,ParallelOptions有三个PropertiesCancellationToken获得或设置一个CancellationTokenMaxDegreeOfParallelism为一个Parallel Loop设置一个最大并发数,如果这个属性被设置为-1相当于没有为起设置最大并发数TaskScheduler为一个Parallel Loop设置一个task scheduler,如果这个值为null,系统将提供一个默认的task sc 阅读全文

Parallel World 3 – Parallel Loop (2)

2011-06-02 11:15 by wildboar, 371 阅读, 0 推荐, 收藏, 编辑
摘要:I. Parallel.ForParallel.For共有12个重载的方法,这里不每个都讲,只说一个最基本的,其他的大家可以自己尝试。 第一个参数, fromInclusive它可以是Int32型的也可以是Int64型的,注意它是inclusive的,也就是说它在循环体中会被用到,在顺序循环Refactor到并行循环时要注意这一点。第二个参数, toExclusive它可以是Int32型的也可以是Int64型的,注意它是exclusive的,也就是说它在循环体中不会被用到,在顺序循环Refactor到并行循环时要注意这一点。它们的区别就类似于下述代码中的0和100这两个值:第三个参数就是一个A 阅读全文

Parallel World 3 – Parallel Loop (1)

2011-05-30 23:45 by wildboar, 600 阅读, 0 推荐, 收藏, 编辑
摘要:在这一系列文章中,我们将会经常用到下面的这些代码, 这些代码中有计算立方和与平方和的代码,没有什么具体意义,只是为了演示并行运算。 1: class Program 2: { 3: private const int NUM_MAX = 100000000; 4: 5: private static void CubicSum() 6: { 7: double sum = 0; 8: var sw... 阅读全文

Parallel World 1 - 并行世界的两个基本问题

2011-05-30 23:42 by wildboar, 200 阅读, 0 推荐, 收藏, 编辑
摘要:Race Conditions(竞态条件) - 一个执行单元修改资源R后,释放了它对R的写访问权,之后又从新获得了对R的读访问权限,再次使用R,并且认为R的状态仍然保持在释放它之后的状态;但是在写访问权限释放后到重新获得对R的读访问权之间这段时间,另一个执行单元实际上已经修改了R。一个典型的竞态条件模型是生产者/消费者模型。Deadlocks(死锁) - 两个或多个执行单元之间相互等待对方结束而引起的组塞情况。比如一个执行单元EU1获得了对资源R1的访问权,另一个执行单元EU2获得了对资源R2的访问权,当EU1请求对R2的访问权时,由于EU2占据着对R2的访问权限,EU1将等待EU2对R2访问 阅读全文

Don't set high speed for the 'Double-Click'

2011-02-22 22:54 by wildboar, 172 阅读, 0 推荐, 收藏, 编辑
摘要:My friends bought a apple bluetooth mouse for me recently, and then I change some settings via 'System Preferences'. and set the speed too fast for the Mouse and Trackpad. a strange problem occurs when I get back to my desktop, when I double-click the folder, I could not open it.  阅读全文

Difference between href and reload for refreshing in javascript

2010-11-18 14:12 by wildboar, 229 阅读, 0 推荐, 收藏, 编辑
摘要:#1.Response.Write("<script language=javascript>window.parent.rightFrame.location.reload();</script>"); #2.Response.Write("<script language=javascript>window.parent.rightFrame.location.href = window.parent.rightFrame.location;</script>");the two ways above 阅读全文

How to delete the cache totally

2010-11-14 16:12 by wildboar, 268 阅读, 0 推荐, 收藏, 编辑
摘要:select the application and click the ‘x’ on the keyboard. 阅读全文

Invalid Date format for webserive

2010-11-14 16:09 by wildboar, 226 阅读, 0 推荐, 收藏, 编辑
摘要:I developed a ipad project, it will use the webservice, but I encounter with an error when I passed some parameters to the webservice, just record as a tip. 阅读全文

How to set UITextField to ReadOnly

2010-11-13 19:55 by wildboar, 618 阅读, 0 推荐, 收藏, 编辑
摘要:textField.userInteractionEnabled = NO; the property is introduced at the UIView class, sometimes it's a good idea to check the superclasses of a given class 阅读全文

How to Use Disk Utility to Erase a Macintosh Hard Drive

2010-10-31 12:08 by wildboar, 629 阅读, 0 推荐, 收藏, 编辑
摘要:This article comes from the following address - http://www.udel.edu/pnpi/tools/erase/mac/erasedisk.htmlYou must reboot your computer using the OS X system CD that came with your Macintosh. To do so, f... 阅读全文