contextswitchdeadlock [英] contextswitchdeadlock

查看:488
本文介绍了contextswitchdeadlock的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然在2008年我所遇到以下错误VS调试我的程序:

Whilst debugging my program in VS 2008 I have come across the following error:

在CLR一直无法从COM上下文0x34fc1a0过渡到COM环境0x34fc258 60秒。拥有目标上下文/公寓线程是最有可能要么做一个非抽水等待或处理一个很长的运行操作,而抽水Windows消息。这种情况一般具有性能产生负面影响,甚至可能导致应用程序变得无响应或内存使用量随着时间的推移不断积累。为了避免这种

The CLR has been unable to transition from COM context 0x34fc1a0 to COM context 0x34fc258 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this

这似乎是死锁即使代码只包含一个简单的C#定时器:见摘录如下图:

It appears to be deadlocking even though the code only contains a simple C# timer: See Snippet Below:

    private void RequestWork()
    {
        // The timer will be re-intialised if there are still no wating jobs in the database
        StopTimer();

        // assign all the threads some work
        InitialiseTimer();

    }



    /// <summary>
    /// Initialise a timer with a timer interval configured from app.config. Enable the timer and 
    /// register an appropriate event handler
    /// </summary>
    private void InitialiseTimer()
    {


        if (m_Timer == null)
        {
            // look up the default backoff time from the config
            string backOffInt = ConfigurationSettings.AppSettings["BackOffInterval"];

            int backoffInterval = 1000;


            m_Timer = new System.Timers.Timer();


            // set the timer interval to 5 seconds
            m_Timer.Interval = backoffInterval;

            m_Timer.Elapsed += new ElapsedEventHandler(m_Timer_Elapsed);
        }

        m_Timer.Enabled = true;
    }


    private void StopTimer()
    {

        if (m_Timer != null)
        {
            m_Timer.Enabled = false;
        }
    }

    void m_Timer_Elapsed(object p_Sender, ElapsedEventArgs p_E)
    {

        RequestWork();
    }



据我所知计时器应该运行,经过,然后再初始化,我可以看到一个僵局没有本地原因。

As far as I know the timer should run, elapse and then initialise again, I can see no local reason for a deadlock.

我知道如何把这个错误味精关闭,但觉得这是不是一个解决方案,取而代之的则是掩盖问题。

I am aware of how to turn this error msg off but feel that this is not a solution, instead it is masking the problem.

推荐答案

可以,如果你认为你已经肯定的关闭这个功能不是的得到了一个僵局情况:

You can turn this off if you think you've definitely not got a deadlock situation:

调试 - >者除外>托管调试助手在Visual Studio菜单,并取消ContextSwitchDeadlock

Debug->Exceptions->Managed Debug Assistants menu in Visual Studio and uncheck the ContextSwitchDeadlock

这篇关于contextswitchdeadlock的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆