Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7866305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:21:16+00:00 2026-06-03T00:21:16+00:00

My code creates a number of Semaphores when it initializes. Each one is associated

  • 0

My code creates a number of Semaphores when it initializes. Each one is associated with a ftp server that my system will communicate with from multiple workflows.
As different instances of the same workflows start I inject the semaphores into the workflows depending on which ftp site that workflow is going to communicate with.

I’m getting a situation where it looks like 2 or more workflows which should contain the same Semaphore are trying to access the ftp servers more times than the capacity of the Semaphore should allow.

I’ve named the Semaphores because I thought I could retrieve the name at the point where the ftp connection is made so that I can check that the correct Semaphore is in the right workflow.

How do I access the name of a Semaphores?

I tried to build an object that inherits from Semaphores and add a name field but this does not work as Semaphore is Sealed

public class MySemaphore : System.Threading.Semaphore
{
   string SemaphoreName = "Bob";
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T00:21:18+00:00Added an answer on June 3, 2026 at 12:21 am

    If you are using .NET 4.0 then use SemaphoreSlim instead. It is not sealed.

    If you must use Semaphore then you will have to create your own class without subclassing it. You will have to punt on the polymorphism so it will not work inside WaitHandle.WaitAny for example, but it is a viable workaround.

    public class MySemaphore
    {
      private Semaphore underlying;
    
      public MySemaphore(int initialCount, int maximumCount)
      {
        underlying = new Semaphore(initialCount, maximumCount);
      }
    
      public bool WaitOne()
      {
        return underlying.WaitOne();
      }
    
      public int Release()
      {
        return underlying.Release();
      }
    
      public string Name { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that creates a number of checkbox elements using Razor code
I'm getting the following error whenever my code creates a DataTableReader from a valid
I have some code that creates a Process instance and later starts it. There's
I have some code that creates a bunch of UITextViews and puts them into
The following code creates the correct number of files, but every file contains the
I have a multidimensional array that contains a variable number of sub arrays. Each
I have a loop that creates a small number of forms on a page.
I have a C code that creates an array of char pointers as the
I'm creating an app that creates buttons through code when an activity starts (the
I have this code that creates the navigation for a slideshow. It works just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.