forum

Home / DeveloperSection / Forums / How to use WPF Background Worker

How to use WPF Background Worker

Takeshi Okada 2145 24-Sep-2013

I am a beginner with WPF, in my application I need to preform a series of Initialisation steps, these take 7-8 seconds to complete during which my UI becomes unresponsive. To resolve this I preform the initialisation in a separate thread:

    public void Initialization()

    {

        Thread initThread = new Thread(new ThreadStart(InitializationThread));

        initThread.Start();

    }

    public void InitializationThread()

    {

        outputMessage("Initializing...");

        //DO INITIALIZATION

        outputMessage("Initialization Complete");

    }

I have read a few articles about the BackgroundWorker and how it should allow me to keep my application responsive without ever having to write a thread to preform lengthy tasks but I haven't had any success trying to implement it, could anyone tell how I would do this using the BackgroundWorker?


wpf wpf 
Updated on 24-Sep-2013

Can you answer this question?


Answer

1 Answers

Liked By