I noticed in my Task Manager I have several copies of this app - though not take any CPU resources.
I know I must be doing something wrong, so I ask the collective...
Here is the sterilized code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Diagnostics;
namespace AnalyticsAggregator
{
class Program
{
[STAThread]
static void Main(string[] args)
{
try
{
bool onlyInstance = false;
Mutex mutex = new Mutex(true, "AnalyticsAggregator", out onlyInstance);
if (!onlyInstance)
{
return;
}
"Do stuff with the database"
GC.KeepAlive(mutex);
}
catch (Exception e)
{
EventLog eventlog = new EventLog("Application");
eventlog.Source = "AnalyticsAggregator";
eventlog.WriteEntry(e.Message, EventLogEntryType.Error);
}
}
}
}
}
I have other console apps that are not mutex/singleton that exhibit the same behavior, what am I doing wrong? I am assuming some type of disposal...
Thanks