eranga262154 22 Junior Poster

Hi all,

I'll explain my question as follows. I have a server application written using C++. Now I try to automate the server to start it automatically. So I write a .Net service to do that.

It's fine, my service is working fine.

But there is one issue. Actually my server can't run multiple server using the same IP. So I want to find is there any server running on specific IP.

So, I used Mutex.

Here what I have done. First get the each server IP from a data base and on each one test there is any instance going on.

private bool HasMultipleInstance(string IP)
		{
			/*
			 * No need to acquire or release the Mutex in .Net
			 * */
			IPMutex = new Mutex( true, IP + "_mutex_" );
			//IPMutex.WaitOne();	

			if( IPMutex != null )
			{
				EventLog.WriteEntry( "MyService", "Multiple Instances on " + IP );
				//IPMutex.ReleaseMutex(); 
				return false;
			}
			else
				return true;
		}

What is your guys comment on this. Is that ok, since my application is a service?