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

  • Home
  • SEARCH
  • 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 6645095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:14:39+00:00 2026-05-26T00:14:39+00:00

I have a webform(c#) application that should only be able to run in a

  • 0

I have a webform(c#) application that should only be able to run in a single instance. Its also important that if the applcation is started again(click on app icon) then the new parameters should be forwarded to the current instance but now application are to be started.

I have ofcouse google the problem and found this : http://www.sanity-free.com/143/csharp_dotnet_single_instance_application.html

This is how I have set it up so far :

public class MyApp : ApplicationContext
{
        private static MyApp _instance;
        private static Mutex _mutex = new Mutex(true, "{8F6F0AC4-B9A1-45fd-A8CF-72F04E6BDE8F}");

        [STAThread]
        public static void Main(string[] args)
        {
             MyParams params;

             params = ExtractParams(args);

             if (_mutex.WaitOne(TimeSpan.Zero, true))
             {
                  _instance = new MyAppp(params);
                  Application.Run(_instance);
             }
             else
             {
                  _instance.SetParameters(params);
             }
        }
}

The problem with this is that the second time I try to start the program I will get an exception in the else that _instance is null?

What am I doing wrong here?

  • 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-05-26T00:14:40+00:00Added an answer on May 26, 2026 at 12:14 am

    In this case, it’s a Inter-process communication (IPC) so _instance doesn’t sense. If you want to have IPC, there’re some ways to do: socket, namepiped, messaging …

    I think 2 methods are suited:

    1. Get the previous process by the process name -> call P/Invoke EnumWindows method to get the main window handle. Send a message with ID has been registered with RegisterWindowMessage before, to pass parameters.
    2. Create a namedpipe server to listen for the parameters of the new process.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a couple mini-applications (single Web form look-up stuff) that need to run
I have an Ajax call (for a HighChartsDB chart) in a WebForm application that
I have a webform (using the ReportViewer) that is in an MVC application. It
In my Webforms 3.5 application, I have a GridView of users that displays the
We have a pretty big ASP.NET WebForm (web application) project with a lot of
I have a WebForm that contains the following definition for the FCKeditor: <FCKeditorV2:FCKeditor ID=txtBody
I have a 3.5 ASP.Net WebForm parent application. The parent uses forms authentication. I
I have an existing asp.net webforms application that I would like to add some
I have an application that prints eTickets. Originally I used the cool 2-D bar
I have a WebForms application hosted in IIS 7. When I run the site

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.