Progress Bar C#

后端 未结 2 730
终归单人心
终归单人心 2021-01-15 05:58

I have a progress bar to show the status of the program loading songs into the library.

    foreach (Song s in InitializeLibrary())
    {
        Library.Add         


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-15 06:48

    The way I have done this is by using a BackgroundWorker component.

    Use it to load your songs on a background thread and report progress to the UI thread that will update your progress bar.

    The background worker handles all of the messaging between threads for the reporting of progress.

    This gets you the benefits of Multithreading without having to manage the threading yourself.

    A good tutorial that will show how to use the progress reporting is here.

提交回复
热议问题