Serial Port 系列(9) 基本篇 -- The Dark Side of the DataReceived Event

DataReceived事件的黑暗面源自於它自己的特性 -- 在次要執行緒上引發 DataReceived 事件,如果你曾經寫過通訊程式會發現一個現象,即使發送端只呼叫一次發送方法,接收端卻有可能會分很多次接收,問題的根源在於傳輸是需要時間的,所以有可能在接收緩衝區還沒收到所有資料前就讀取緩衝區,一個簡單的方式是你可以使用這系列文之前簡單的發送端 與接收端,然後去觀察你每次所收到的資料。

...繼續閱讀 »

Serial Port 系列(7) 基本篇 -- 建立一個簡單的純發送程式(多緒型範例)

經過了上一篇的說明,應該都瞭解基本發送的做法,記得我在 [Serial Port 系列(2) 在開始寫程式之前]提到了多執行緒,現在就用多執行緒來實做發送。
為什麼通訊的部份應該要放在多執行緒中呢?有幾種狀況我們會遇到,例如像單次通訊的時間很長、亦或使用大量甚至無限迴圈進行通訊,在使用者操作軟體的時候你不會希望聽到他說:「我按了通訊後你的程式就當掉了,畫面都不會動。」諸如此類的評論;所以我一向很習慣把通訊寫在另一個執行緒來執行。這個會複雜點,希望你們有耐心看得下去。



...繼續閱讀 »

Serial Port 系列(1) 關於Serial Port的基本認識

不論是在論壇或是部落格上,長久以來關於序列埠程式的開發一直都還有滿多人在詢問相關的議題,也因此讓我想要寫一個關於這方面比較完整的系列文,只是我這個大懶鬼不曉得要花多久時間才能把整個系列做完。不過這總是個開始,第一篇咱們不談程式,先來瞭解序列埠的基本知識。

...繼續閱讀 »

老調重彈 -- 再談 Windows Form 程式視窗互相傳值(1)

這算是個老掉牙的問題了,雖然題目叫『再談』,但事實上我從來沒有特別在這部落格上寫過這題目;不過這個主題很熱門,也有很多人寫過,而且他們寫的都還真不錯。比如像Larry的 [.NET Concept][C#][VB.NET].NET兩個表單間的資料互通 、 Jeff Yeh的 幾種WinForm的Form與Form之間的傳值方法;不勝枚舉,恕我就不一一列出了。

...繼續閱讀 »

How to change the file permissions in Windows Installer file

Sometimes, we need to write something to file (ex: mdb, txt, …), not only read it. For example, you build an application which need update or insert data to an access mdb file, when you install this application to C:\Program files directory (or C:\Program files(X86), if you installed a X86 application into a X64 Windows), it will work perfectly in Windows XP environment. But how about Window Vista/7 ?

...繼續閱讀 »

Porting your Silverlight apps to IADP

Jeff Chu and I studied how to porting Silverlight application to IADP last several weeks. After we read “HOW TO: Installing the XNA framework from your MSI installer using Visual Studio 2008 and XnaInstaller”, we thought that if XNA Apps can be submitted successful, Silverlight apps should be, too.

Just a few days ago, I submitted a Silverlight and it has been validated. So, we prove that this is indeed feasible. Now, let’s go through the procedures to know how to do it.

...繼續閱讀 »