Partilhar via


Basic Threading in .NET CF (Compact Framework) or Generally .NET

As I mentioned in my NEAT-o-Games post, on Friday I visited CPL to see talk about Windows Mobile Development.  I provided an overview of threading concepts in .NET CF and gave a quick demo of basic threading concepts.  If you are new to threading in either .NET or .NET CF, this demo show how an interface can become unresponsive and how to use threading to solve this problem.  If you're brand new to Windows Mobile, stay tuned for a later post on a quick Hello World for Windows Mobile 6 ... I couldn't find a simple and easy link for this.  (Thanks to Clint Rutkas for helping me put this together).

A quick overview:

This application shows examples of creating, sleeping, and invoking threads and uses delegates methods.  This application has 2 display items and three mode buttons and attempts to do 5 seconds worth of work behind the scenes.  A timer is displayed below the three mode buttons the timer demonstrates the responsiveness of the user interface by attempting to update each second.  The Status Display in the bottom shows the UI being updated after the 5 seconds of work has been accomplished.

 

The three mode buttons demonstrate different designs of the 5 seconds of work.

Work:   demonstrates the 5 second workload contained in the main thread

Work-Threaded:  demonstrates the 5 second workload contained in a worker thread

Work-Smarter Thread:   demonstrates the worker thread updating the User Interface through the Main Thread

 

Download the Threading Code Example and the Threading PowerPoint.

 

Share this post :

Comments

  • Anonymous
    April 24, 2008
    I like it, one of my students will make use of this example in class. :)