我有一个的Windows Mobile 6.5(.NET CF 3.5),使用下面这个模式的单例类:上Singleton类创建活动
public sealed class Singleton
{
static readonly Singleton instance=new Singleton();
// Explicit static constructor to tell C# compiler
// not to mark type as beforefieldinit
static Singleton()
{
}
Singleton()
{
}
public static Singleton Instance
{
get
{
return instance;
}
}
}
我的类用于从收集的GPS数据中间驱动器。我想要的是在我可以订阅的单例类上创建一个事件?例如。 MyClass.Instance.LocationChanged + = ...;
任何帮助将不胜感激。
马克
请注意,订阅该事件的任何代码必须*显式*取消订阅它。不这样做会导致内存泄漏。 – 2010-12-16 15:06:04