11.14.2005

Remoting and Generic

這兩天試了試Remoting,發現之前有關於Generic的部份要加以修改,我想他是可以使用的,然而卻有部分的限制。

這兩天都在試動態Load Assembly,然後掛到Service上面,是的,可以做,也運作的非常好。不過之前測試的版本卻不行,這兩天,我想要找出來哪裡有錯。

另外有關於Remote Object的解構式,他比較特別的是,Server端的GC並不會去呼叫。

我本來的想法是把一個Singleton Remote Object當作一個Cache,在Constructor時讀取資料庫,然後所以的資料變動都放在他身上,然後當Client沒有動作超過五分鐘(Singleton Object Default Life Time),會呼叫解構式,那時候再寫進Database,不過,測試的結果似乎是GC並不會去Run這一段,Remote Object就直接消滅了。

修改:有關上面這一段,我有再做一個測試,就是在解構式裡面寫檔案,當然,當五分鐘過後再開一個新的Client去呼叫,會起一個新的Remote Object, 但是當Remote Service Close掉時,卻會呼叫這個Remote Object的解構式。所以上面那一段的說法有問題,應該是說GC會去處理,但是處理後並不一定會馬上消滅這個物件,消滅這個物件的準確時間看來部是我們可以知道的,所以不管怎麼說,把寫入資料庫的動作放在解構式看來很不智,呵呵。

這兩天要測試當List 或是 SortedList 包含可序列化的 Complex Object,是否可以使用在Remoting上面。

還有就是兩個版本的Load Assembly,為啥一個能跑,另一個不能跑。

--------------------------------------------------------------------

Here are practice for English writing, welcome any comment for grammar or tech.

I had test Remoting and Generic this week, and find out the way to run, there are some limited when using generic in remoting. So…the posted article is wrong.

I also test the way to dynamically load assembly and plug into remoting service. Indeed, It's work, the better thing is so smooth. I need to find the difference between the versions, because I spent a lot to turn the first version and cannot run till.

Beside that, I find the special thing about destructor of remote object. The special thing is that GC in the server side would not to call destructor when the object disposed.

The original blueprint of my idea is using singleton remote object as cache for some usual table in database. The remote object load data from database in constructor and whole change are imply in the object. Than, when five mins gone and no client call it, the object would to write data into database in destructor (the default life time for singleton object are five mins without any client call). But the result of this test is that seems GC would not call the object's destructor and dispose it directly.

Fix: I run another test after post this. The test is put an write file code in the remote object's destructor and wait the lift time. After five mins pass and I run a new client to call the remote object, the data show the object is new because the data had input was gone. But the write file code run in the time I close the service. The conclusion is the GC in server side would mark the disposed object but do not clear it immediately, the time point would be control by GC and we had no way to know. Whatever, put the code that write change into database into destructor is silly, ha.

Ok, next week I would test that is remoting could run with the generic container that contain the complex object. And the version difference.

No comments: