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

volatile modifier


  • Please log in to reply
4 replies to this topic

#1 rhind

rhind

    New Member

  • Members
  • Pip
  • 3 posts

Posted 02 June 2011 - 10:35 AM

When declaring some types as volatile e.g. private volatile int i; I get a Predefined type 'System.Runtime.CompilerServices.IsVolatile' is not defined or imported NetDuinoMMC error. Is volatile not allowed in .Net MF or is it not required? If its not available, how to we work around it without doing a full 'lock' on an object?

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 02 June 2011 - 11:02 PM

Hmm, really interesting. We always use monitors (locks) for this--so I've never tested that on .NET MF before. I wonder how hard it would be to create a System.Runtime.CompilerServices.IsVolatile type for .NET MF (much like the method extension class was added by the community). Chris

#3 Corey Kosak

Corey Kosak

    Advanced Member

  • Members
  • PipPipPip
  • 276 posts
  • LocationHoboken, NJ

Posted 03 June 2011 - 01:04 AM

Is volatile not allowed in .Net MF or is it not required? If its not available, how to we work around it without doing a full 'lock' on an object?

I think your best bet is the Interlocked. family of operations (CompareExchange, Increment, and the like)

#4 rhind

rhind

    New Member

  • Members
  • Pip
  • 3 posts

Posted 03 June 2011 - 07:46 AM

Hmm, really interesting. We always use monitors (locks) for this--so I've never tested that on .NET MF before.

I wonder how hard it would be to create a System.Runtime.CompilerServices.IsVolatile type for .NET MF (much like the method extension class was added by the community).


Hi Chris, Can you provide a link to info on the method extension class that I can look at?

I think your best bet is the Interlocked. family of operations (CompareExchange, Increment, and the like)


Yes these would be better than doing a lock, but I really don't they shouldn't be necessary, just need to disable caching of a couple of variables.

I'll implement it with these for now.

Cheers

Russell

#5 stotech

stotech

    Advanced Member

  • Members
  • PipPipPip
  • 143 posts
  • LocationAustralia

Posted 07 August 2012 - 02:39 AM

I've got the same problem. I'm trying to do multithreading described http://msdn.microsof...a2f3ay4(v=vs.80).aspx . Can someone explain what to use instead.




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.