开发者

Single user implementation for a specific application

I have a requirement like this.

  1. My application is an add-in to Excel. It uses a token to authorize a specific user.

  2. There is a Red/Green indicator in the add-in to show application is online/offline.

  3. If A is already logged-in by opening an Excel instance, my re开发者_如何学运维quirement is when other Excel instance is opened in the same machine, it should use the existing logged in information and show the status as online/offline in the new Excel instance. I saw an implementaion using Semaphore. However not sure whether that can be a good solution solving my needs.

How to achieve this requirement?


well a semaphore is good if you want to limit the number of instances, but in this case you don't, you want to do some very simple IPC. If it were my requirement I would add a WCF service bound to localhost or named pipes.

on startup try to connect to it and find out what user is logged in, if you can't connect to it start the server. You will also need some mechanism for another instance to take over server role in case the user closes the instance hosting the service.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜