Home→Forums→MonoBrick EV3 Firmware→Brick-Simulator?→Reply To: Brick-Simulator?
Martin Wagner
Hi Anders,
sorry, the singleton implementation is DotNet4 stuff and I don’t know whether it runs in Mono.
(Source: http://geekswithblogs.net/BlackRabbitCoder/archive/2010/05/19/c-system.lazylttgt-and-the-singleton-design-pattern.aspx)
#region SingletonStuff
// ensures that only one instance of this class can exist, so everybody writes and reads the same variables
private ButtonHAL() { } // hiding creator
// static holder for instance, need to use lambda to construct since constructor private (DotNet4 only)
private static readonly Lazy<ButtonHAL> _instance = new Lazy<ButtonHAL>(() => new ButtonHAL());
// accessor for instance
public static ButtonHAL GetSingleton { get { return _instance.Value; } }
#endregion //SingletonStuff
Can one of the mono experts have a look at it?
Thanks,
Martin
Follow