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

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?

Thanks,
newbieweb

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

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:
http://www.codeproject.com/KB/IP/remotingchatsample.aspx
Random Solutions  
 
programming4us programming4us