Create Event on Singleton Class

后端 未结 2 434
不思量自难忘°
不思量自难忘° 2021-01-28 17:29

I have a Windows Mobile 6.5 (.net cf 3.5) that uses a singleton class which follows this pattern:

public sealed class Singleton
{
    static readonly Singleton in         


        
2条回答
  •  情话喂你
    2021-01-28 18:06

    What's the problem?

    public sealed class Singleton
    {
      ... your code ...
    
      public delegate LocationChangedEventHandler(object sender, LocationChangedEventArgs ea);  
    
      public event LocationChangedEventHandler LocationChanged;
    
      private void OnLocationChanged(/* args */)
      {
        if (LocationChanged != null)
          LocationChanged(this, new LocationChangedEventArgs(/* args */);
      }
    }
    
    public class LocationChangedEventArgs : EventArgs
    {
      // TODO: implement
    }
    

    Call OnLocationChanged whenever you want to fire the event.

提交回复
热议问题