How to make a resource (screen) available to only one user at a time in a .Net distributed application?

I have a client server based windows based application that only needs an admin screen. The administrator functionality should be implemented in such a way that only one administrator can access this screen at a time. The window renders the client application on the server using .NET Remoting. And the server side is distributed across multiple machines.

+1


source to share


2 answers


The easiest way to do this is with a DB table. Typically, the database is fault-tolerant and a secure resource to share. Just run the lock table which contains some information about the locked resource, which has it, when, etc.

You can also use one of the various "government servers" on the market to store the lock state. This introduces a point of failure, though, unless you're investing in one of the new distributed state technologies.



However, you are really setting yourself up for further problems. You will need a screen that allows you to force unlock, see who has the lock, etc. Your best bet is to look at why this castle is really needed. Is it a technology or business requirement? You can more easily and cleanly implement a pessimistic data refresh scenario that will improve the user experience.

+3


source


You need to keep a static member on the server that indicates if this window is being used. Make sure it is thread safe by using the lock () function when setting a value. Then you can check this value before displaying the admin screen.

As for the server side, you say that it exists on multiple PCs. Is it a balanced topology type balance that acts as a single virtual server? If so, you may need to store the value in the database. Think of it the same way that Session State is stored in ASP.Net . I can exist on the server, but if there is a server farm, it can be migrated to SQL Server for use by all servers.



0


source







All Articles