Click or drag to resize
NetworkSemaphore Class
Keeps track of concurrent users of an application on a network by using semaphore files in a shared network location.
Inheritance Hierarchy

Namespace: com.softwarekey.Client.Licensing.Network
Assembly: PLUSManaged (in PLUSManaged.dll) Version:
public class NetworkSemaphore

The NetworkSemaphore type exposes the following members.

Public methodNetworkSemaphore
Creates a new NetworkSemaphore object.
Public propertyCleanupThreadInterval
Gets or sets how frequently, in seconds, the cleanup thread tries to delete each semaphore file. The default is 10 seconds.
Public propertyIsValid
Gets whether or not the network session is still valid.
Public propertyLastError
Gets the last error that occurred.
Public propertySeatsActive
Gets the number of concurrent users.
Public propertySeatsAvailable
Gets the number of remaining seats available.
Public propertySeatsTotal
Gets or sets the number of allowed concurrent users.
Public propertySemaphoreName
Gets the name of the open semaphore file. Returns an empty string if no semaphore file is open.
Public propertySemaphorePath
Gets or sets the absolute path of the directory used to house the semaphore files.
Public propertySemaphorePrefix
Gets or sets the prefix used when creating semaphore files.
Public propertyValidationThreadInterval
Gets or sets how frequently, in seconds, the validation thread checks that the network session is still valid.
Public methodCancelSearch
Cancels the search in progress.
Public methodClose
Closes an open network semaphore file.
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodOpen
Opens a network semaphore file.
Public methodSearch
Performs an asynchronous search for an unused network semaphore file. Requires handling the SearchCompleted and optionally the SearchProgress events.
Public methodToString (Inherited from Object.)
Public eventInvalid
Occurs when the network session is no longer valid.
Public eventSearchCompleted
Occurs when the search for an unused seat/semaphore file has been completed.
Public eventSearchProgress
Occurs when progress is made in searching for an unused seat/semaphore file. The SearchProgress event may be used by your application to keep a user informed of the progress being made while searching through semaphore files.

A Network Semaphore File is a file, which contains no useful data, stored on a common network directory used to assist in enforcing a Network Floating License in an application. One file is created and locked exclusively for each active workstation or instance of your protected application. Other LAN users attempting to run the application will not be able to use any semaphore files that are locked, which is how this can enforce license compliance which limits the number of network "seats."

Caution note Caution

Any users who will use an application using this type of licensing will need access to read, write, modify, and delete the semaphore files.

Caution note Caution

This functionality is supported on environments where semaphore files are hosted on a Windows (SMB/CIFS) share, which functions best on a Local Area Network (LAN). While this may be used in a Wide Area Network (WAN) environment (which includes scenarios where a user access a given "LAN" over a Virtual Private Network [VPN] connection), it is strongly advised testing is done before deploying to any given WAN environment. This is because the performance of this feature is centered around that of the Windows (SMB/CIFS) shares being used to host the semaphore files (and WAN/VPN environments can see much slower performance than a typical LAN configuration).

Caution note Caution

The NetworkSemaphore class is only supported when the system hosting the Windows (SMB/CIFS) share which houses the semaphore files, and the clients which access the share, all run Windows Vista/Windows Server 2008 or later.

Note Note

The computer hosting the Windows (SMB/CIFS) share (the server) which houses the semaphore files is ultimately responsible for handling when a file is unlocked. In most cases, applications which are terminated gracefully will unlock and delete their semaphore files. If the application crashes, however, the server will eventually unlock the semaphore file, but it will not delete the file. Having many of these files present can lead to some performance degradation, as each of these orphaned files can take a while to try to lock or delete. For this reason, the NetworkSemaphore constructor has a "runCleanupThread" argument, which may be set to true to have active processes try to delete orphaned files quietly, in the background. Of course, this will increase the amount of bandwidth used, but can help increase performance keeping the share location clear of any orphaned files.

See Also