WeakDelegate Sample

This sample shows how to use the Micro Framework’s WeakDelegate class to notify the object of events. A WeakDelegate allows the object to have its memory reclaimed as long as the application has no other references to the object (forcing it to stay alive). The results are displayed in the debugger’s Output window.

Features

  • Shows how to define an event that uses WeakDelegate objects to refer to the objects that have registered interest in the event.
  • Shows how to create an object and register it with an event supporting WeakDelegate objects.
  • Shows how a strong reference to the object ensures that it receives notification when the event is raised.
  • Shows how no strong references to the object allows a garbage collection to destroy the object. Consequently, the object will not receive any further notifications when the event is raised.

How To Build

  1. Navigate to the Microsoft .NET Micro Framework\Samples\WeakDelegates subfolder of your My Documents folder.
  2. Load WeakDelegates.sln into Visual Studio.
  3. Build the WeakDelegates solution.

Note

This sample is designed to demonstrate a feature or functionality of the SDK within the Micro Framework Emulator. The sample may require modification to function properly on your hardware.