Search code examples
.netsecurityc#-4.0code-access-security

Slow performance with SecuritySafeCriticalAttribute on win server 2008


My Application spend too many time on Wait method

Environment:

  • .Net 4.0
  • App Platform x86
  • Console app
  • win server 2008 (x64)

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);
        }
    }
}

Solution

  • 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