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 - Invoking a user interface update from a thread

Now, we are going to make the necessary changes to the Encrypter class to allow it to invoke a user interface update when it completes the encryption algorithm:

  1. Stay in the project, MarsEncrypter.
  2. Open the code for the Encrypter class.
  3. Add the following line of code at the beginning:
    using System.Windows.Forms;
    
  4. Add the following private variable:
    private frmMarsEncrypter proForm;
    
  5. Add the following properties to access the private variable (we want to create a compact and reliable class):
    public frmMarsEncrypter poForm
    {
    set
    {
    proForm = value;
    }
    get
    {
    return proForm;
    }
    }
    

    Note

    In this case, to simplify the examples, we will use a delegate to make a direct call to a method in the form, holding ...

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