O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

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

Track Multiple Clients with a Singleton

Problem

You want to allow multiple clients to communicate with each other through a single server.

Solution

Create a server-side singleton object that tracks all the currently available clients on the network. The server should store a proxy object for each client in an in-memory collection.

Discussion

When you create a remote object that uses singleton activation mode, only a single instance of it will be created. All the clients that use this remote object will access the same instance. This means that the remote object can store some information that will be shared among all users (such as a list of connected clients). It also means that you’ll need to craft thread-safe code using the techniques presented ...

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