Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to implement backgroundworker in WPF and C#

What I have tried:

As i am new to wpf technology.Plese help me out.
Posted
Updated 6-Apr-20 23:38pm

You do it the same way you do it anywhere else. WPF is not "special" in this regard.
 
Share this answer
 
The way you do with any app using it.
Create the instance, handle the events, and start it:
C#
BackgroundWorker work= new BackgroundWorker { WorkerReportsProgress = true };
work.ProgressChanged += Worker_ProgressChanged;
work.DoWork += Worker_DoWork;
work.RunWorkerCompleted += Worker_Completed;
work.RunWorkerAsync(myParameterIfAny);
And then write the event handlers:
C#
private void Worker_DoWork(object sender, DoWorkEventArgs e)
    {
    ...
    }
private void Worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
    ...
    }
private void Worker_Completed(object sender, EventArgs e)
    {
    ...
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900