Solved
Looks like dottrace show the weather. I've checked performance by ANTS Performance Profiler and fixed the issue. Problem was in sql request thru NHibernate
Question
My Application spend too many time on Wait
method
Environment:
I've checked performance by dottrace
Wait
is marked by SecuritySafeCriticalAttribute
Please note on Win7 (x64) all works fine. I found nothing, any suggestions are welcome.
Task Processing
private readonly BlockingCollection<TTask> _queue = new BlockingCollection<TTask>();
private Thread _workThread;
public void ProcessTask(TTask task)
{
_queue.Add(task);
}
private void ProcessTask()
{
while (_isRun)
{
try
{
TTask task = _queue.Take();
if (task.IsNull())
{
continue;
}
_log.DebugFormat("Sending task: {0}", task);
DoProcessMessage(task);
}
catch (Exception ex)
{
_log.Error(ex);
}
}
}
La solution 2
Solved
Looks like dottrace show the weather. I've checked performance by ANTS Performance Profiler and fixed the issue. Problem was in sql request thru NHibernate
Autres conseils
I don't think security attribute affects the speed. Long time on Wait here takes lots of time probably because you access the guarded object (some collection) from multiple threads concurrently and keep the object locked for long time (eg. while your code processes each item in the collection). This is not a proper way to use collection and definitely a bottleneck in your code.