天天看點

Silverlight - Silverlight for Windows Phone中的Render 線程

Silverlight for Desktop中沒有單獨的render thread,跟界面相關的操作都運作在一個UI thread中。之是以不像WPF那樣設計一個單獨的render thread,Ashraf Michail是這樣解釋 的:

Since WPF provides a rendering thread, it is probably surprising that Silverlight does not. You may be interested to know why.

The decision came down to a tradeoff between system overhead and decoupling framerates . With Silverlight, we went with a lighter weight on-thread approach and did not isolate your application code from the rendering system. That means you can do more in your animation (like have layout-based animation or custom code running) and there is minimal latency and overhead getting to the rendering system. The down side is if you do too much, you can interfere with operations such as video playback. That said, the Silverlight rendering system will take advantage of multi-core processing and use many threads to speed up rendering for it. So, rendering is rarely "on thread," (感覺是筆誤,應為 "one thread") but it is synchronized with your app to avoid synchronization plus copies of data.

當然Silverlight for Desktop中并不是所有的系統代碼都在一個UI thread中,還有一些 子線程用來處理rame rasterization, media decoding and GPU marshalling等操作 。

Silverlight for Windows Phone卻設計了一個單獨的render thread, Seema Ramchandani的Siverlight Performance on the Windows Phone 的示範中提到:

Silverlight - Silverlight for Windows Phone中的Render 線程

圖:Silverlight for Windows Phone 中的render thread 能做什麼