Limit number of users in c# application

c#, client-server, winforms

Solution

You will potentially need the concept of a "session" to identify the concurrent number of users.

If want this to be done in a fail-safe manner, you will have to introduce an application layer between your DB server and the client. You can then provide methods to login and logoff for users.

At every login you will need to increment a count of "concurrent users" and at every logoff you will need to decrement.

You may need to introduce the concept of session time-out as the some of the clients may shutdown without invoking the logff method.

The number of concurrent users allowed can be associated with a license.

Problem

I am developing a Client-Server application using C#. Basically the server is a SQL server and the clients are developed in C#. What I would like to know is the best way (if any) to limit the number of users using the application at any one time - say I wish to limit to two users. Would I limit their access to SQLserver?

Original source