I am writing a small forms based application to connect to an LDAP server, and I wanted the \"connect\" button to work in the background. So I was following the information and
RunWorkerAsync()
starts the worker thread and immediately returns thus the debugger seems to "step through it". Set a breakpoint in the worker_DoWork()
method.
You have not set
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
before calling worker.RunAsync()
You are never wiring up the event.
public Form1()
{
InitializeComponent();
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
}
If u still have event and is not working, try the following
Just call
System.Windows.Forms.Application.DoEvents();
before calling RunWorkerAsync()