好消息: Firefox 3 Release Candiate 1 Code Complete!

[quote]
Thanks to all the hard work of the Mozilla community as of 9:15 AM PDT today we are code complete for Firefox 3 Release Candidate 1 (RC1). New nightly builds are available – if you are a nightly tester/Minefield user you can help test these builds by selecting “Check for Updates” from your help menu.

Assuming no new issues are found today the build team will start official prep work for Release Candidate 1 (RC1) tomorrow. QA will start their extensive RC1 test pass on Monday. If all goes well we should have the Release Candidate publicly available in late May.

RC1 is intended for wider scale public testing. Our 1.2M+ active beta users will automatically get updated to RC1 when it is released. If no new showstopper issues are found in RC1 it will become Firefox 3 final. If we find any critical issues we will continue to release new Release Candidates until we are ready for final ship.

[/quote]

Microsoft.NET Framework源代码能供人瞻仰了;)

期待已久的.NET Framework终于在本周开源了,微软在MS-RL协议下终于公开了.NET Framework源代码,我们只可以自由查看,不允许直接进行修改。
第一批开放的源代码包括:

.NET基本类库:
System,System.CodeDom,System.Collections,System.ComponentModel, System.Diagnostics, System.Drawing, System.Globalization, System.IO, System.Net, System.Reflection, System.Runtime, System.Security, System.Text, System.Threading

ASP.NET:
System.Web, System.Web.Extensions

Windows Forms:
System.Windows.Forms

Windows Presentation Foundation:
System.Windows

ADO.NET和 XML:
System.Data
System.Xml

详情请访问ScottGu的文章:http://weblogs.asp.net/scottgu/archive/2008/01/16/net-framework-library-source-code-now-available.aspx
如何在Visual Studio 2008中进行配置请参考这篇文章:
Configuring Visual Studio to Debug .NET Framework Source Code

http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx

关于net2.0里面新出现的类backgroundworker的应用

这是一个在.net2.0里面新出现的类,用于执行后台比较长的任务而又想能和UI有点操作的应用里面。

普通情况下,你点击一个按钮,去后台执行一个process,如果你想得到结果,就得等这个process结束。通常,可以使用异步执行回调来解决这个问题。现在,backgroundworker给我们实现了这样一种简单的封装,可以把我们的复杂任务交给新的线程去处理,然后继续UI线程。等到我们的任务需要通知UI做什么事情的时候,可以report一下,在其事件里就可以直接使用UI控件,而不需要Control.Invoke去掉用之。

有这样一个应用:客户需要把大量数据(需要执行3天)copy到另外一个机器,中间想能看到有多少数据被复制/失败等(实时报道)。

在这个例子里面,我们的界面可能非常简单:一个开始按钮,一个结束按钮,一个richtextBox来显示运行记录。但是后台执行可能就会比较棘手。如果简单的执行,并且报告,那么整个界面将失去响应(都在同一个线程里面,造成忙碌)。这时候,可以使用这个backgroundworker了。它可以在后台执行,并且报告给界面实时信息,界面不会失去响应。

先介绍一下backgroundworker的几个属性/方法

.WorkerReportsProgress:是否可以向外报告进度。

.WorkerSupportsCancellation :是否可以暂停任务

. CancellationPending: 是否正在暂停中

. RunWorkerAsync() : 开始执行任务。触发DoWork事件

. ReportProgress(int percentPrgress,object userState) : 向外报告进度。触发ProgressChanged事件.其中,参数可以在ProgressChangedEventArgs(worker_ProgressChanged(object sender, ProgressChangedEventArgs e))中得到

. CancelAsync() :取消(暂停)执行。

事件

worker.DoWork += new DoWorkEventHandler(worker_DoWork);//执行任务

worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);//任务结束时

worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged)//报告状态

按照上边的资料,我们这个应用就可以这样处理之

formDisplay是用于显示实时状态的窗口。有DisplyMessage方法来显示信息到界面

在Hanlder类(处理文件copy的)里面:

static void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)

{

//show the message on windows

formDisplay.DisplyMessage(“copy”, e.UserState.ToString());//show message.

}

static void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)

{

string msg = "JOB copy : have been completed";

formDisplay.DisplyMessage(msg);//show message

}

static void worker_DoWork(object sender, DoWorkEventArgs e)

{

for(…)

{

//copying

(sender as BackgroundWorker). ReportProgress(0,”xxx complete”);//report

}

}

这样构造的程序里面,才不会出现UI失去响应。

当然,通过写自己的异步处理也可以实现,功能更强大。只不过这个用起来更简单。

至于backgroundworker是怎么实现的呢?这里有人已经做出了一些解答:

http://blog.joycode.com/sunmast/archive/2006/03/02/about_system_componentmodel_asyncoperation.aspx