WebBrowser event properties?

Can I find out if a function is assigned to an event?

eg. (Standard winforms application with web browser control)

namespace Crawler {
    public partial class Form1 : Form {

        WebCrawler.manager m;

        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e) {
            system.windows.forms.webbrowser wb = new system.windows.forms.webbrowser();
            wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(foo);

            //[... Some other code ...]

            /* [Begin Example] */

            if (wb.DocumentCompleted.Contains(foo){

                // Behave Normally

            }else {

                // Do Something Else...

            }
        }
    }
}

And if I can do something like the one described above, then how?

+1
source share
1 answer

You can call Deletegate.GetInvocationList.

Here is an example:

using System;
using System.Linq;

class Program
{
    static event Action foo;

    static void bar() { }

    static void Main()
    {
        foo += bar;

        bool contains = foo
            .GetInvocationList()
            .Cast<Action>()
            .Contains(bar);
    }   
}
+1
source

Source: https://habr.com/ru/post/1708102/


All Articles