Time for action – simulating a bank queue with multiple tellers

My bank has a token management system. So as you visit the bank, you have to collect a token. Each token has a number printed on it and the numbers show up against teller counter numbers, on a giant screen. It also shows which token numbers are still to be serviced.

This is a concurrent situation. We can simulate this either with a ConcurrentQueue or with a ConcurrentStack. Let's see how:

  1. Create a Windows application and place controls on the form, as shown in the following screenshot:
    Time for action – simulating a bank queue with multiple tellers

    Also, add the following reference to your project and add them at the start of Form1.cs:

    using System.Collections.Concurrent; ...

Get .NET 4.0 Generics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.