I use them for “communication” between different objects, as publisher and subscriber pattern.
Is some examples I see that sometimes event is declared as static and sometimes it’s not:
public delegate void LogProgress(string str)
public static event LogProgress LogProgressEvent;
if (LogProgressEvent != null)
LogProgressEvent(tempString);
Why and when I need to use static?
Static events are actually quite dangerous, and (fortunately) also quite rare. As with anything static, you would use it when it applies to the type generally, not any specific instance. And even then, you might see it on a singleton instance rather than as a static event.
The danger is that it is ludicrously easy to forget to unsubscribe, and end up keeping masses of objects alive forever; contrast to most instance-based events – usually, the instance will go out-of-scope eventually, making the delegates collectable (a delegate instance will keep a target instance alive).