Log in

View Full Version : More .NET Compact Framework Sample Code


Andy Sjostrom
11-21-2003, 10:34 AM
Microsoft has recently published a number of additional code sample downloads built using .NET Compact Framework. Download and store away to your own "tool box" of good-to-have utilities!

Performance Counter (http://www.microsoft.com/downloads/details.aspx?FamilyID=0cc40dae-2615-431f-a674-99e6135f3b56) - This sample demonstrates how to P/Invoke the QueryPerformanceFrequency and QueryPerformanceCounter functions to create a high resolution timing solution.

Splash Screen (http://www.microsoft.com/downloads/details.aspx?FamilyID=33817ce0-b5e9-4b8e-916b-e6a381e03789) - This sample demonstrates how to create a splash screen form on a separate thread from the main form. The splash screen will periodically update a "busy" animation and shut down when either the form has finished loading or a specified amount of time has elapsed, whichever comes last.

Stopping Threads (http://www.microsoft.com/downloads/details.aspx?FamilyID=aaf04053-d348-47e1-a9c3-d8b577bbe665) - The code in this sample resides in a single Form and demonstrates how to safely shut down a Form with multiple threads running. The Form contains a single button which launches a new thread. Each thread subsequently sits in an infinite loop invoking a counter updating function and waiting for a close request. When the application is closed, the main form waits until all threads are removed before shutting down.

Save Bitmap (http://www.microsoft.com/downloads/details.aspx?FamilyID=554acd82-d87d-43c6-a984-8c625387b198) - This example demonstrates how to load a bitmap from a file, draw it to a surface, allow the user to modify it, and then save it to a file. In the .NET Compact Framework, there is no simple method for saving Bitmap objects or getting a bitmap handle from a Bitmap object so it is necessary to use a bit of trickery to access a bitmap's pixel data. This example will access a bitmap's pixel data through a device context created from an editor control.

Performance Measurement (http://www.microsoft.com/downloads/details.aspx?FamilyID=fcedc338-6cd2-4d7e-a0cd-c8b355ed4fe5) - Learn how to measure and tune the performance of your Microsoft® .NET Compact Framework-based applications.

Bitmap Copy (http://www.microsoft.com/downloads/details.aspx?FamilyID=0fbfde9c-4e76-45e9-b083-e25ccbed9dfd) - This sample demonstrates two Copy functions for copying Bitmap objects. The first function returns a Bitmap object containing a specified region of a source Bitmap object. The second returns a Bitmap object which is a copy of the original source Bitmap object.

Power Status (http://www.microsoft.com/downloads/details.aspx?FamilyID=e69968f9-5fc2-4456-852a-757f32312d91) - This sample demonstrates how to P/Invoke the GetSystemPowerStatusEx and GetSystemPowerStatusEx2 functions, each of which fill a SYSTEM_POWER_STATUS_EX and SYSTEM_POWER_STATUS_EX2 class respectively. These classes contain information about the batteries and power status of the device.

MSI that Detects Framework Version (http://www.microsoft.com/downloads/details.aspx?FamilyID=cadec6e7-1383-4944-aedb-52cb5e8eb529) - This sample describes how one might create an MSI package which can detect the presence of the Microsoft .NET Compact Framework on a device, determine if the device needs to be upgraded with a newer version, and install or upgrade the Framework along with an application.