Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Does ExtendedWeakReference work?


  • Please log in to reply
2 replies to this topic

#1 Corey Kosak

Corey Kosak

    Advanced Member

  • Members
  • PipPipPip
  • 276 posts
  • LocationHoboken, NJ

Posted 17 October 2010 - 07:12 PM

This is my program. Each time I run it, it says "Sorry, didn't find existing item." It appears to not be persisting the EWR.

Should I expect ExtendedWeakReference to work?

using System;
using Microsoft.SPOT;

namespace hacks.netduino.sandbox {
  public class Program {
    public static void Main() {
      var oldValue=ExtendedWeakReference.RecoverOrCreate(typeof(Zamboni), 0,
        ExtendedWeakReference.c_SurvivePowerdown|ExtendedWeakReference.c_SurviveBoot);

      var blah=oldValue.Target as Blah;
      if(blah==null) {
        Debug.Print("Sorry, didn't find existing item");
        blah=new Blah();
      } else {
        Debug.Print("Existing value is "+blah.value);
      }
      ++blah.value;
      Debug.Print("new value is "+blah.value);
      oldValue.Target=blah;
    }
  }

  public class Zamboni { }

  public class Blah {
    public int value=0;
  }
}


#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 17 October 2010 - 07:19 PM

Hi Corey, ExtendedWeakReferences are not supported. We recommend using an SD card shield (or Netduino Plus with integrated SD) for data storage. All that said, we _could_ enable EWR support on the Netduino--but it would take up to 16KB of the available code space. Would that be worth it? Chris

#3 Corey Kosak

Corey Kosak

    Advanced Member

  • Members
  • PipPipPip
  • 276 posts
  • LocationHoboken, NJ

Posted 17 October 2010 - 07:38 PM

Would that be worth it?


Nobody should do anything solely on my account, because I'm just playing around. But in a pony-complete world, the firmware would consult some kind of boot-time flag to decide whether that particular 16KB is allocated to code or EWR. Then, only EWR-using apps would have to pay this penalty.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.