The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
[UWP]Using BackgroundWorker in UWP app RRS feed

  • Question

  • Hello guys

    as i said in the title, and i want to use this class because i want a way to run an background task and during the job i can report the progress of the job and use that information to update the UI.

    if it's not possible then is there another way to do so?


    • Edited by Breeze Liu Monday, October 9, 2017 2:04 AM [UWP]
    Friday, October 6, 2017 2:50 PM

Answers

  • I don't think BackgroundWorker shows up in .Net Standard until .Net Standard 2.0, so you can't use it in an earlier .Net Standard library. You can check the .Net Standard docs at https://docs.microsoft.com/en-us/dotnet/standard/net-standard and follow the version links to the GitHub projects for each version.

    • Marked as answer by Lersubem Sunday, May 27, 2018 10:56 AM
    Thursday, October 12, 2017 12:49 AM

All replies

  • What are you actually trying to do? Background Worker is available to UWP apps, but it is very different from BackgroundTasks.
    Friday, October 6, 2017 3:01 PM
  • I just want to makea a class that run in background, and this class will use events to report the progress and i want to update the progress bar when so.

    For example, a background downloader that download something from the internet and update the progress bar during downloading.

    My question is how to achieve so?

    Friday, October 6, 2017 6:25 PM
  • Depending on your specific needs you can use a BackgroundTask (which will run in the background even if your app is suspended) or a BackgroundWorker (which will run in the background while your app is running and will suspend with the app).

    For the specific case of downloading use the BackgroundTransfer API.

    Friday, October 6, 2017 7:38 PM
  • The BackgroundWorker will do the job, can you help me with an example of how to use it?

    Friday, October 6, 2017 7:46 PM
  • There is sample code in the BackgroundWorker documentation at https://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker(v=vs.110).aspx

    You will need to swap out the UI code from WinForms to UWP, but the BackgroundWorker code is the same.

    Saturday, October 7, 2017 1:54 AM
  • I would like to use this class in .NetStandard 1.3

    is that possible?

    bcause i cant find BackgroundWorker class under the name space System.ComponentModel

    Saturday, October 7, 2017 9:21 AM
  • I don't think BackgroundWorker shows up in .Net Standard until .Net Standard 2.0, so you can't use it in an earlier .Net Standard library. You can check the .Net Standard docs at https://docs.microsoft.com/en-us/dotnet/standard/net-standard and follow the version links to the GitHub projects for each version.

    • Marked as answer by Lersubem Sunday, May 27, 2018 10:56 AM
    Thursday, October 12, 2017 12:49 AM