Delphi-PRAXiS
Seite 3 von 3     123   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   limiting number of instances in Windows terminal server (https://www.delphipraxis.net/200895-limiting-number-instances-windows-terminal-server.html)

imadam 5. Jun 2019 09:24

AW: limiting number of instances in Windows terminal server
 
Zitat:

Zitat von mjustin (Beitrag 1433929)
Did you try TJvAppInstances already? It is designed for limiting app instances, and it allows to set the maximum number of simultaneous instances using the property MaxInstances. I am not soure however if it is also suited for a TS.

No, I haven't tested it. Will review. But on initial aim, this won't help.

Schokohase 5. Jun 2019 09:28

AW: limiting number of instances in Windows terminal server
 
Delphi-Quellcode:
TJvAppInstances
will limit the applications inside the SESSION.

So => yes, this will work on TS too.

But, a single user can open more than one session on a TS (you can limit it optional to only one session per user).

imadam 5. Jun 2019 09:30

AW: limiting number of instances in Windows terminal server
 
Zitat:

Zitat von Schokohase (Beitrag 1433938)
Delphi-Quellcode:
TJvAppInstances
will limit the applications inside the SESSION.

So => yes, this will work on TS too.

But, a single user can open more than one session on a TS (you can limit it optional to only one session per user).

Have you tried it already?

peterbelow 5. Jun 2019 10:40

AW: limiting number of instances in Windows terminal server
 
Zitat:

Zitat von imadam (Beitrag 1433893)
Hello,
I can read a little of German, but to write, not possible. So here is my question in English:
I have Delphi app which need to execute in Windows Terminal Server (nowdays RDS). We would like to be able to control how many instances user can run in their session. So for example:
- user 1 can run two instances of app 1
- user 2 can run 1 instance of app 1

We are able to fix this on Windows to have only one instance of application running but on TS is a bit problem for us. Anybody had similar problem?

Thank you.

This is the classical scenario for a licence server. You have a separate process (Windows or web service) running on a known platform. This process accesses a repository of licenses assigned to specific users. This can be a simple file. When your program is started it identifies the current user (Windows GetUsername API function) and then asks the licence server whether there is a free licence for that user available. If not it exits with a suitably ascerbic error message. If a licence is available it claims it from the server, usually giving the server a combination of computer name or ip address and process ID as a means to identify the claimer of the licence for the licence admin. When the application ends it returns the licence to the server.

The main problem in this scenario is how to deal with unexpected termination of the program holding the licence. In this case the licence is not properly returned to the server for later reuse. How to handle that depends on specifics of the environment. You can, for example, implement a mechanism that allows the server to check at intervals whether the processes having a licence in use are still running. Or you can require the program to regularly "renew" the claim they have on a licence, e.g. at 10 minute intervals. The licence is then reset to available if two of these intervals have passed without a renewal of the licence.

Schokohase 5. Jun 2019 11:14

AW: limiting number of instances in Windows terminal server
 
Zitat:

Zitat von imadam (Beitrag 1433939)
Zitat:

Zitat von Schokohase (Beitrag 1433938)
Delphi-Quellcode:
TJvAppInstances
will limit the applications inside the SESSION.

So => yes, this will work on TS too.

But, a single user can open more than one session on a TS (you can limit it optional to only one session per user).

Have you tried it already?

I do not need to try - I saw the source code and I saw how it is implemented and working

imadam 5. Jun 2019 11:30

AW: limiting number of instances in Windows terminal server
 
Zitat:

Zitat von Schokohase (Beitrag 1433946)
Zitat:

Zitat von imadam (Beitrag 1433939)
Zitat:

Zitat von Schokohase (Beitrag 1433938)
Delphi-Quellcode:
TJvAppInstances
will limit the applications inside the SESSION.

So => yes, this will work on TS too.

But, a single user can open more than one session on a TS (you can limit it optional to only one session per user).

Have you tried it already?

I do not need to try - I saw the source code and I saw how it is implemented and working

Ok :-). Thank you.

imadam 5. Jun 2019 11:59

AW: limiting number of instances in Windows terminal server
 
Zitat:

Zitat von peterbelow (Beitrag 1433944)
Zitat:

Zitat von imadam (Beitrag 1433893)
Hello,
I can read a little of German, but to write, not possible. So here is my question in English:
I have Delphi app which need to execute in Windows Terminal Server (nowdays RDS). We would like to be able to control how many instances user can run in their session. So for example:
- user 1 can run two instances of app 1
- user 2 can run 1 instance of app 1

We are able to fix this on Windows to have only one instance of application running but on TS is a bit problem for us. Anybody had similar problem?

Thank you.

This is the classical scenario for a licence server. You have a separate process (Windows or web service) running on a known platform. This process accesses a repository of licenses assigned to specific users. This can be a simple file. When your program is started it identifies the current user (Windows GetUsername API function) and then asks the licence server whether there is a free licence for that user available. If not it exits with a suitably ascerbic error message. If a licence is available it claims it from the server, usually giving the server a combination of computer name or ip address and process ID as a means to identify the claimer of the licence for the licence admin. When the application ends it returns the licence to the server.

The main problem in this scenario is how to deal with unexpected termination of the program holding the licence. In this case the licence is not properly returned to the server for later reuse. How to handle that depends on specifics of the environment. You can, for example, implement a mechanism that allows the server to check at intervals whether the processes having a licence in use are still running. Or you can require the program to regularly "renew" the claim they have on a licence, e.g. at 10 minute intervals. The licence is then reset to available if two of these intervals have passed without a renewal of the licence.

You can look at it from that point. And it is good point. However, here main reason is to prevent users hogging RDS server since they open multiple application to use (it is easier for them) and if you have 100 users opening up same up 3-4 times, then it is like 400 users on server which should support 100 users :-)


Alle Zeitangaben in WEZ +1. Es ist jetzt 07:12 Uhr.
Seite 3 von 3     123   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz