thread does not work, it's freezing my application : <p>I have a function with several loopings and database query, I want to call it asynchronously by passing a progress bar to show the user the progress.</p>

<p>When I call the thread the program hangs I can not even close</p>

<p>when I call synchContext.Post (state => etlBusiness.LoadData (progressBar), null); it freezes, it is not feasible to bring the logic of loadData to UI there are many methods being called the inside</p>

<pre><code> public partial class Home : Form
{
    public Home()
    {
        InitializeComponent();
        synchronizationContext = System.Threading.SynchronizationContext.Current;
    }

    private SynchronizationContext synchronizationContext;

    public SynchronizationContext context = SynchronizationContext.Current;

    public Thread _myThread = null;
    private void btnSend_Click(object sender, EventArgs e)
    {
        _myThread = new Thread(() =&gt; LoadData(synchronizationContext, progressBar1));

        _myThread.Start();

    }

    private void LoadData(System.Threading.SynchronizationContext synchContext, ProgressBar progressBar)
    {
        string filePath = tbPath.Text;
        ETLBusiness etlBusiness = new ETLBusiness(filePath);

        synchContext.Post(state =&gt; etlBusiness.LoadData(progressBar), null);
        _myThread.Abort();
    }

}
</code></pre>
