SUMTEC -- There's a thing in my bloglet.

But it's not only one. It's many. It's the same as other things but it exactly likes nothing else...

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  263 随笔 :: 19 文章 :: 3009 评论 :: 74万 阅读
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

先来看一下.NET CF的一些新消息,其实就一条:
.NET Compact Framework 1.0 的 SP2 发布了!下面是两个连接,我也闹不清楚到第哪个才是给开发者使用的:
.NET Compact Framework 1.0 SP2 Developer Redistributable (Re-release) 12677 KB

.NET Compact Framework 1.0 SP2 Redistributable (Re-release) 14776 KB

哎,随便啦,反正我暂时不打算用。因为有一个很现实的问题:PDA上面也需要打这个补丁,除了会额外占用空间之外,还有一个问题就是PDA上面会掉电!万一掉了点了,那就回到原来的版本上面了。如果我原来设了Button的Backcolor为Color.Green,现在掉了电之后回到了SP2以前的状态,就变会原来的Color.White了。我可不希望那么丑的东西会出现,我宁愿是用自己的PicButton来完成这个功能,毕竟这些掉了电一安装就好了,我可不希望在安装包里面再加一个SP2的包,那样要有要变大不少……。

不用归不用,SP2还是很令人兴奋的,以至于我希望他不叫做SP2而叫1.1。这样各个厂商就得要跟风,就得要重新制作他们的Image了,我们就不需要头痛了,我们可以声称“我们只支持PPC2003/II”了。下面是一些改进的地方:

.NET Compact Framework 1.0 Service Pack 2 details:

Performance & Other Improvements List:
- Improved performance of many data tasks, including populating DataSets, searching DataTables, DataSet.ReadXml() method when a schema is used, finding and indexing operations, setting DataSet.EnableConstraints property
- Improved resource loading performance
- Minor GUI performance improvements
- Extend keyboard events to be enabled on all controls (Control.KeyUp, KeyDown, KeyPress)
- Added support for ForeColor &/or BackColor for Button, Checkbox, ComboBox, DomainUpDown, Label, Listbox, ListView, NumericUpDown, RadioButton, Trackbar, TreeView
- Added support for new Smartphone languages: Finnish, Czech, Romanian, Slovakian, Norwegian, Hungarian, Polish, Turkish, Russian
- Improved Control.Enabled and Control.Parent property changing performance
- Support menu hotkeys on Pocket PC
- Support raising context menus from assigned hardware key, Pocket PC
- Tab support for Pocket PC based on Z-Order
- XmlTextReader performance improvements

Defect Fix List:
- Fixed crash when SQLClient or SQLServerCe is installed.
- DataRowCollection.Find() method throws wrong exception
- Fixed erroneous parsing of HttpWebRequest response stream
- Form does not get the focus when all controls are removed from the form
- InputPanel Button disappears from MainMenu on Pocket PC 2002
- InputPanel's EnabledChanged Event fires inspite of setting the enabled property to the same value.
- IrDAClient.DiscoverDevices device names garbled
- Memory leak in the NumericUpDown, DomainUpDown, ComboBox and TextBox controls
- Native Exception occurs when using the get accessor for Control.Capture
- Navigation bar flickers when new form is being loaded.
- ObjectDisposedException occurs when DataBinding a control to a form shown via Show()
- OK button eventually goes away when re-using recycled form for ShowDialog()
- Setting the InputPanel.Enabled property when the form is closing throws an exception
- SIP button does not go away when the toolbar control is removed from a form that does not have a menu
- The Focus method does not work correctly for the NumericUpDown and DomainUpDown controls
- The Text property of a ListView column is reset to “” when removing the column from the ListView and then adding it back.
- ContextMenu: Fixed TreeView issues on Pocket PC 2003
- ContextMenu: Fixed side effects on controls like Scrollbar and Label
- ContextMenu: erroneous functionality when bound to ListBox
- ContextMenu: Showing a context menu on Pocket PC for a textbox unselects the selected text in the textbox
- ContextMenu: Empty ContextMenu on Pocket PC should not pop up
- Web services: After repeatedly canceling asynchronous web request, all web service calls fail
- conversion of 0.0F to a string and results in a memory leak
- Web services: An XmlException is thrown when deserializing a qualified name that has no prefix and there is no default namespace defined
- Web services: Incorrect handling of null headers in SOAP message

我们可以注意到SIP有所改进,窗口焦点可能有所改进,Backcolor等属性有所改进,KeyXXXEvent有所改进,Parent改变的时候效率有所提高,TextBox弹出“弹除式菜单”的时候再也不会消除已经选中的字符了(意味着我们可以做Copy/Paste之类的东西了,虽然这是最基本的东西,可是以前就是不能够用),在TreeView上面弹出菜单的问题也解决了……这些是我精选出来、让我感到最为兴奋的地方。这些改进可以说是一个小跨越,因为基于这个SP2进行开发的程序很可能会在SP2以前的CF里面出错,甚至根本就不能够用。

说了老半天了,跟Singleton好像没什么关系。不,还是有点关系的。正因为没有SP2的优化,所以现在加在窗口的速度非常慢,尤其有很多个不同的窗口的时候。因为过去为了方便,我们一次过生成了所有的窗口,所以会等很长很长的时间。虽然有想过在需要用到的时候再创建相应的窗口,可是由于没有想到Singleton模式,于是想将这部分代码写到要用这个Form的地方,所以显得非常麻烦!今天早上的时候,我突然想到实际上我们现在的Form基本上不需要实例化多个,而只需要重复利用就行了——实际上考虑到PDA的资源问题,我们基本上不可能实例化太多的窗口。虽然我们都是这么想,可是也许我们用C#用太久了,忘记了用VB做开发的时候,实际上就是一种类似Singleton的模式,我们那个时候用了这么就Singleton,现在怎么就忘了呢?其实是昨天还是前天我在CSDN上面回复的一个贴子提醒了我,应该这么去做CF下面的开发。

今天下午我就这么改了一通,效果还是很明显的!改的方式就和我回复的一模一样。

当然,解决效率问题的办法还有很多。比如应用一些别的设计模式,比如FlyWeight和(Virtual) Proxy。FlyWeight实际上是非常有必要的,因为一个构造函数没有任何代码的对象的创建,所消耗的时间是int加减操作的二十倍!也就是说在这期间你可以做二十次的加减赋值等操作,这么多操作一般足以创造一个可以被使用的FlyWeight对象了(当然指的是已经被Pooling的),而这个时候你的对象仅仅是创建出来了,但还没有调用构造函数呢!关于Proxy我就不多说了,看过设计模式就应该知道有什么效果。

其实,我还有一个招数,就是用我自己写的一个优化器,据说优化后的启动时间会缩短30%~70%!(这个是根据发现这个优化原理的人测试出来的。)当然,我不太清处在SP2里面是不是还有一样的效果。

今天就写到这里吧……


文章来源:http://dotnet.blogger.cn/sumtec/articles/161.aspx
posted on   Sumtec  阅读(1377)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
点击右上角即可分享
微信分享提示