FlushExtendedWeakReferences

I am using EWR to save user parameters on EMX platform. The size of object stored in EWR can be variable and I need a way to ensure that data are properly written.

Actually, I am using the following code to manage saving:


public void SaveSettings()
        {
            // It is enough to set the Target property in order to write the data into FLASH.
            restoreReference.Target = this;
            restoreReference.PushBackIntoRecoverList();
            GHI.Premium.System.Util.FlushExtendedWeakReferences();
            //give the system time to save it to flash
            Thread.Sleep(5000);
        }

This works great but 5 seconds to wait is an empirical value and would like to know if there’s a way to know if it can be reduce without damage. As data are serialized, I don’t know the needed space and can not interpolate with the writing speed of flash on LPC2478.

A good thing could be to have a blocking call for the flush method:
http://www.ghielectronics.com/downloads/NETMF/Library%20Documentation%20v4.2/Premium/html/9a82ee8e-8915-25e0-96c6-30acf2a7376d.htm

Do you think this could be done in futur?

What about this?

EWR is 64K on EMX and SDK4.2.10. Let say that my data take all the amount of flash. The datasheet of LPC2478 says that saving 256bytes on flash takes about 1ms. Therefore saving 64K should take 256ms… Am I wrong?

I personally hate EWR :slight_smile: Complicated and results are random.

Now, to your question, if you use flush (which GHI added to help with problematic EWR) then you do not need a delay, I do no think. But again, this is EWR!!

I wish Microsoft would replace this with something more direct and simple, with guaranteed data. If you open an issue here http://netmf.codeplex.com/ I will gladly vote for it.

Hello Gus. I agree with you about robustness of EWR and the fact that EWR processing is hidden is really painfull when EWR can not be restored. I would also prefer to have a fine grain management of this (may be something that allows to adress flash directly is possible?)

I will check on CodePlex to see if there’s already issue on EWR.

Let’s vote on codeplex: https://netmf.codeplex.com/workitem/2010

Do not hesitate to comment and add your own experience directly on codeplex

You got it