Main Site Documentation



I have sample Test, and upload to my board.

Oprtationg is so good.

but sevral Time I turn off and turn on the board,

the Speed become low. and EWR doesn;t storage my data.

Q1) Why EWR dont work?

Q2) what is the method ExtendedWeakReference.FlushAll(); ??

under my Code

using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Touch;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Input;

namespace StorageManagerTest
//TargetClass: static vs. instance
//float(value type) is possible?
//Wrap float with class(Ref. Type)

public class Program : Application
    private Window mainWindow;

    public static TestClass testClass;
    public ExtendedWeakReference settingsReference;
    public Rectangle rect;
    public static void Main()
        Program myApplication = new Program();
        Window mainWindow = myApplication.CreateWindow();

    public Window CreateWindow()
        mainWindow = new Window();
        mainWindow.Height = SystemMetrics.ScreenHeight;
        mainWindow.Width = SystemMetrics.ScreenWidth;

        Canvas can = new Canvas();
        Debug.Print("Test StorageManager");

        rect = new Rectangle();
        rect.Height = SystemMetrics.ScreenHeight;
        rect.Width = SystemMetrics.ScreenWidth;
        Canvas.SetRight(rect, 0);
        Canvas.SetBottom(rect, 0);
        rect.Fill = new SolidColorBrush(Colors.Blue);

        settingsReference = ExtendedWeakReference.RecoverOrCreate(typeof(TestClass), 0, ExtendedWeakReference.c_SurvivePowerdown);
        settingsReference.Priority = (Int32)ExtendedWeakReference.PriorityLevel.System;

        if (settingsReference.Target == null)
            testClass = new TestClass();
            testClass.number = 2;
            Debug.Print("Class Null value");
            rect.Fill = new SolidColorBrush(Colors.Blue);                
            Debug.Print("Result: " + ((TestClass)settingsReference.Target).number.ToString());
            rect.Fill = new SolidColorBrush(Colors.Red);                
        settingsReference.Target = testClass;

        mainWindow.Child = can;
        return mainWindow;            

public class TestClass
public float number;


EWR is not written directly into flash. It’s delay written, wen CPU is idle.
In the GHI Utility namespace there is a method to flush EWR immediately.


so i wonder the ExtendedWeakReference’s version

Microsoft.SPOT.Native.dll, v4.3.1.0: there is FlushAll method

Microsoft.SPOT.Native.dll, v4.1.2821.0 : there is not FlushAll method

so, if i use v4.1.2, i need thread.Sleep for write to flash?

and i wonder how many sleep time i need?