Week 7a - Processes and Threads

Models and simple examples

Synopsis:

This lecture introduces threading models and a few simple examples.

Readings and Activities for the Week:

Glossary of Terms

  1. The Syllabus describes topics to be covered, reading material for you to digest as part of each lecture, and due dates for assigned projects.
  2. Projects:

  3. Midterm Exam

    You may wish to look ahead at Topics and materials to study for the Midterm Examination in next week's lecture page Wk #8a.
  4. Basic Windows Concepts

  5. Windows Processes

  6. Threads

  7. Code Demos:

    Starting Threads, Code Snaps
    Discusses several ways to create .Net threads.

    Basic Thread Demos, WPF Thread Demos
    Fairly simple examples of thread applications.

    Blocking Queue using Monitor, Code Snap
    Blocking Queues are very useful for sending messages between threads - helps to keep threading models simple.

    Queued Messages with BlockingQueue
    This is a queueing demo.

    Abstract Task Model - BasicTasks project
    .Net Tasks simplify communication between parent and child threads.

    async await pattern - WpfWithAsync project
    Using tasks in GUI applications.

    WPF Dispatcher Invoke Demo
    Child threads are not allowed to directly communicate with a parent window.
    Here's how to manage child thread to UI-thread communication.

    .Net FormInvoke Demo
    Same demo, but for legacy WinForms.
  8. Preparation for Synchronous Discussion:

    • Write pseudo code for a small threading demonstration program that:
      • Starts two child threads.
      • In the first child thread, create the text for a string.
      • The second child then displays the string contents on the console.
      Hint: to share the string contents you may need the StringBuilder reference type.
      You will need to lock the string when reading or writing its contents.
      Be prepared to discuss your solution.
  9. Lecture Take-aways:

    The most important things we discussed are: