TheGateKeeper
TheGateKeeper

Reputation: 4530

Static classes and "this" keyword

I have a static class with a custom event in it, as below:

    //The delegate
    public static delegate void eventDoneDelegate(object sender, WebLoaderEventArgs e);

    //The event that uses the delegate
    public static event eventDoneDelegate PageRequestDone;

    //Calls the event
    private static void onPageRequestDoneChanged(WebLoaderEventArgs e)
    {
        if (PageRequestDone != null)
            PageRequestDone(this, e);
    }

I know "this" can't be used because it references the current instance, but how can I pass the currect class as a parameter?

Or maybe my logic is wrong, please aware me as I am new to this.

Thanks.

Upvotes: 1

Views: 70

Answers (1)

Christian Hayter
Christian Hayter

Reputation: 31071

The semantic meaning of the sender argument value depends on a vague agreement between the event publisher and the event subscribers; there is no universal standard. In your example, I can't see any need for a sender value at all, you might as well pass null.

Upvotes: 2

Related Questions