O'Reilly logo

C# 2008 and 2005 Threaded Programming: Beginner's Guide by Gastón C. Hillar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - Creating a safe method to update the user interface

The quality assurance team discovered a bug in the encryption dispatcher. As they were working with huge files, they realized that the file names were appearing in the listbox before the encryption job began. That sounds confusing. They want you to change the application and add the file names in the listbox as soon as the work gets completed.

That sounds easy for a BackgroundWorker component, but this time, you cannot use it because you would have to introduce a loop in the BackgroundWorker thread. Instead, you can invoke a delegate from the worker thread to update the user interface safely.

Now, we are going to add a new method and a delegate to the form in order to allow the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required