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 7953863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:15:26+00:00 2026-06-04T03:15:26+00:00

I am working on multi instance application. Is there any way in c# to

  • 0

I am working on multi instance application. Is there any way in c# to know that how many instances are running currently.
I used one peice of code to count the window processes of my application name but that is not a good way.

string fileName = Process.GetCurrentProcess().MainModule.FileName;
int count = 0;
foreach (Process p in Process.GetProcesses())
{
    try
     {
        if (p.MainModule.FileName == fileName)
        {
            count++;
        }
    }
    catch { }
}

MessageBox.Show("Total Instances Running are " + count);

Can it be done by using semaphore or some increment and decrement counter that is incremented by one when new instance is created and decrement by one when a instance closes.

  • 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-04T03:15:28+00:00Added an answer on June 4, 2026 at 3:15 am

    A Semaphore helps you count down, blocking you when you get to 0. You could use a global semaphore, but you’ll have to initialize it at a high enough-value and start counting down.

    I think all in all, your own solution is probably the cleanest.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a multi-instance appalication there is application update function that downloads
I'm currently working on a multi-tenant application that employs Shared DB/Shared Schema approach. IOW,
I'm working on a multi-monitor kiosk application that needs to run full-screen on both
I'm working on a multi-lingual WPF project that will be localized into many different
I'm currently working on a multi-threaded application, and I occasionally receive a concurrently modification
I'm currently working on a Sudoku application, the numbers are stored within a Multi-Dimensional
I'm working on a multi-threaded C# Windows application that makes frequent calls into a
I am currently working on a Silverlight 4.0 Application that displays about 13.000 rows
I'm working on integrating a single-threaded API that does not have any multi-threaded support
I have a PHP based multi-threaded application that I'm try to get working with

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.