Hey guys!

I have a question. I have this code:

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            int count = listView1.Items.Count;
            int threads = 5;

            LinkChecker[] lc = new LinkChecker[count];

            int trace = 0;
            for (int i = 0; i < count; i++)
            {
                for (int k = 0; k < threads; k++)
                {
                    lc[k] = new LinkChecker(this);
                    ThreadPool.QueueUserWorkItem(new WaitCallback(lc[k].DoChecking), trace);
                }
            }
        }

and

delegate void DelegateDoChecking(object sender, int id);
        public void DoChecking(object sender, int id)
        {
            if (form1.listView1.InvokeRequired)
            {
                DelegateDoChecking del = new DelegateDoChecking(DoChecking);
                object[] items = { sender, id };
                form1.listView1.Invoke(del, items);
                return;
            }

            string url = form1.listView1.Items[id].Text;

            if (CheckLink(url))
            {
                string a = anchor;
                form1.listView1.Items[id].SubItems.Add("Found");
                form1.listView1.Items[id].SubItems.Add(a);
                form1.listView1.Items[id].BackColor = Color.FromArgb(237, 252, 211);
            }
            else
            {
                form1.listView1.Items[id].SubItems.Add("Not Found");
                form1.listView1.Items[id].BackColor = Color.FromArgb(253, 231, 231);
            }
        }

But that threadpool says that there's no overload for DoChecking.

Anybody knows what should I fix ?

Please copy and paste the exact error message

Here it is:

No overload for 'DoChecking' matches delegate ' System.Threading.WaitCallback'

WaitCallback delegate (line 14 in first block of code) only takes one parameter and you are giving it a two parameter method (DoChecking has two parameters).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.