.NET: Microsoft Technologies based on the .NET software framework. Runtime: An environment required to run apps that aren't compiled to machine language.
Hello,
Semaphores are of two types: local semaphores and named system semaphores. Local semaphores are local to an application, system semaphores are visible throughout the operating system and are suitable for inter-process synchronization. The SemaphoreSlim is a lightweight alternative to the Semaphore class that doesn't use Windows kernel semaphores. Unlike the Semaphore class, the SemaphoreSlim class doesn't support named system semaphores. You can use it as a local semaphore only. The SemaphoreSlim class is the recommended semaphore for synchronization within a single app. Update:
Although Semaphore's API documentation mentions that communication can be done via system semaphores. However, system semaphores cannot be declared by a program.
Tokens are obviously a custom persistence variable, which means that this cannot be achieved with Semaphore.
For your needs, since the token is in its lifetime, there are two programs that need to read it. Therefore, it's really a persistence problem for a variable rather than a synchronization problem.
For variable persistence, you can easily do this through a file.
For file persistence, you can write it to a file when the token is generated. After that, you can read this file from the Worker and Client to verify the token.
Since you only need to read and write to a file, you can refer to this official example.
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.