Does that mean every body is using just one Worker Process? in the case the performance is horrible.
I have been using 3 worker processes since two weeks, it do help a lot for concurrent visits. The only issue I ran into so far is "Duplicate Emails"
https://www.nopcommerce.com/boards/t/19148/duplicate-emails.aspx?p=2
I digged into the code and find that problem is TaskManager. It is not thread safe/ inter Process safe.
All 3 worker processes are running the tasks, so sometimes customers got 3 duplicate emails.
I personally solved this problem in the TimerHandler, which check MUTEX and ensure no group of tasks run at the same time.
I'm happy to share with you guys who have the same problem.
private void TimerHandler(object state)
{
//[JD] make exclusive access, do NOT run tasks simultaneously
string appGuid = ((GuidAttribute) Assembly.GetExecutingAssembly().GetCustomAttributes(typeof (GuidAttribute), false).GetValue(0)).Value;
string mutexId = string.Format("Global\\{{{0}}}_{1}", appGuid, Seconds); //so that at least this group (grouped by seconds) won't run
using (var mutex = new Mutex(false, mutexId))
{
var hasHandle = false;
try
{
try
{
hasHandle = mutex.WaitOne(1000, false);
if (hasHandle == false) return;
}
catch (AbandonedMutexException)
{
hasHandle = true;
}
#region do work
this._timer.Change(-1, -1);
this.Run();
if (this.RunOnlyOnce)
this.Dispose();
else
this._timer.Change(this.Interval, this.Interval);
#endregion
}
finally
{
if (hasHandle) mutex.ReleaseMutex();
}
}
}
Yet still, I don't think it is an elegant solution.
The Code for TaskManger/Task/TaskThread are not really clean, need to be reworked.
Properties like "IsRunning" are useless.
Maybe Andrey could have some time clean the things up.