Enginerds

23/01/2009

One app per computer

Filed under: Uncategorized — Mart Leet @ 16:34

Just one little code snippet for bookmarking. This is snipper for console application. With Windows app you could use Application.Exit(). I could do some machine process name comparing, but that’s gives me only current user processes.

static void Main()
		{
			Mutex instanceLock = new Mutex(false, "My.Unique.Name.What.Should.Be.Quid");
			if (instanceLock.WaitOne(0, false))
			{
				try
				{
					var listener = new Listener();
					listener.Start();
				}
				finally
				{
					instanceLock.ReleaseMutex();
				}
			}
			else
			{
				Environment.Exit(5);
			}
		}

And this is my first wordpress post (in their editor, because my live writer is one big wuss). Congratulations to me!

Advertisement

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.