[Last Call] Learn how to a build a cloud-first strategyRegister Now


I need to run multi-instances of my WinForms app. Any issues?

Posted on 2009-12-31
Medium Priority
Last Modified: 2013-12-17
I need to run multi-instances of my WinForms C# application. What issues can I expect?

I'd like to use the same EXE. BUT, each instance will be associated with a unique copy of an Access database. Each is a different restaurant with a unique identifier.

1) How can the program know if a given restaurant is already running? I want it to load no more than one time per restaurant.
2) I use Microsoft MapPoint's ActiveX control. Will they automatically share it and will Windows handle the multi-user aspect of this use?
3) I intend the first instance to be the only instance which can dispose of the MapPoint ActiveX COM object. Refreshing this instance is an important thing to do to keep it working properly I am told by Microsoft, at least for the 2004 version.
4) How can I make different instances of the EXE communicate with one another?

What difficulties/challenges does this model present?

Question by:newbieweb
1 Comment

Accepted Solution

Eric_Dahlvang earned 2000 total points
ID: 26157519
1) Create a mutex, using the name of a restaurant.  When a new instance of the application starts, retrieve the list of restaurant names from a shared database, and run through the list of restaurants attempting to obtain a mutex for each one until you get one you are able to obtain.  If you cannot obtain any of the mutexes based on the restaurant names, then every restaurant application is already running, so just shut down.

see here: http://www.codeproject.com/KB/cs/SingleInstanceAppMutex.aspx

2) As for sharing the MapPoint activex control in more than one process...it should be easy to figure out if you cannot find any documentation.  Create an application with the map point control, and run it twice...look in the task manager and see if the MapPoint process is created twice.

3) When you close your application, go through the mutex process again, and if you are able to obtain every mutex, then your instance is the last instance running...so dispose of the COM object.

4) Use .net remoting to communicate between instances of your application.  Register the channels using the restaurant name, then you can communicate with every other restaurant application intance on the channel that matches the restaurant name.

see here:

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month17 days, 16 hours left to enroll

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question