Performance in .NET Compact Framework

Performance in .NET Compact framework can be improvised by concentrating on the following areas1.Base Class Library2.Framework

ITPro Today

April 7, 2004

11 Min Read
ITPro Today logo in a gray background | ITPro Today

Performance in .NET Compact framework can be improvised by concentrating on the following areas 1.Base Class Library2.Framework


Overview

Performance in .NET Compact framework can be improvised by concentrating on the following areas

1.       Base Class Library

2.       Framework

 Base Class Library

Performance Improvement

Best Practices / Performance Techniques

Arrays and Collections

          Use Strongly typed arrays where possible

          Use Jagged, not multidimensional arrays

          Presize Collection classes appropriately

String

          Use String builder class for complex string concatenation and manipulation

1.       Strings are immutable

2.       String.Concat() causes unnecessary copies

          Do not use foreach () to enumerate characters in strings.

Whidbey Performance

          String class Improved

1.       One object instead of two

2.       Improved string collection

 

Framework 

Performance Improvement

Best Practices / Performance Techniques

Windows Forms

          Load and Cache Forms in the background

           Parent controls Top-Down

          Form Panels Controls

 ߧ          Use BeginUpdate / EndUpdate when it is available

          Example List View / Tree View

           Keep Event Handling Code tight

          Process bigger operations asynchronously          Blocking in event handlers will affect UI responsiveness

Graphics and Games

          Compose to off-screen buffers to minimize the direct to screen blitting (Apprx 50 % faster)

           Avoid transparent blitting in areas that require performance (Apprx 1/3 speed of normal blitting)

           Consider using pre-rendered images vs using System.Drawing rendering primitives (Needs to measure on a case- by case basis)

           Override OnKey methods on controls instead of adding key event handlers (OnKeyDown / OnKeyUp / OnKeyPress)

XML

          Use XMLTextReader and XMLTextWriter

          Smaller memory footprint than using XMLDocument

          XMLTextReader is a pull model parser that only reads a Window of the data.

          Design XML Schema first and then code

          Understand the structure of your XML document

          Use elements to group

          Use attributes to reduce size

Data

          If data is local. instead of Dataset.

          Leverage SQL CE native in-proc database

          Query data using DataReader

          Use TableDirect command type for fast index searches

          Limit Open SqlCeCommand/DataReaders

           If data is remote

          Use SQL CE Replication

          When using Web Services

          Use DiffGrams to read and write Datasets to limit data transfer

          Save Data locally in SQL CE for faster access and storage

          Dont Save remote Datasets as XML to device

XML and Data (Whidbey Performance

          Vastly improved XMLTextReader and XMLTextWriter

          XMLSerializer

          Xpath

          General Data Improvements (DataSet.ReadXml)

          Improved ADO.NET performance with SQL CE 3.0 (SqlCeResultset)

 

Read more about:

Microsoft
Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like