简体   繁体   English

VS2012是BSOD Causer

[英]VS2012 Is A BSOD Causer

So after 36 hours of research and checking, I got it. 经过36个小时的研究和检查,我得到了它。

VS2012 Is the cause after the 'process has locked pages' BSOD. VS2012是“进程已锁定页面”BSOD后的原因。

I tried to open a thread to get the active IPs on my network (using C#). 我试图打开一个线程来获取我的网络上的活动IP(使用C#)。 Apparently, When you press the 'Stop' Button when the thread is active, windows is crushing. 显然,当线程处于活动状态时按“停止”按钮时,窗口会破碎。

This is the thread code: 这是线程代码:

    private void Button_Click_2(object sender, RoutedEventArgs e)
    {

        var thread = new Thread(() => TryToConnect(targetsList));

        thread.SetApartmentState(ApartmentState.STA);
        thread.Start();
        thread.Join();

    }

    private static void TryToConnect(ListBox targetsList)
    {
        for (int i = 1; i < 3; i++)
        {
            Uri url = new Uri("http://192.168.1." + i.ToString());
            string pingurl = string.Format("{0}", url.Host);
            string host = pingurl;
            Ping p = new Ping();
            try
            {
                PingReply reply = p.Send(host, 3000);
                if (reply.Status == IPStatus.Success)
                {
                    ListBoxItem item = new ListBoxItem();
                    item.Content = "192.168.1." + i.ToString();
                    targetsList.Items.Add(item);
                    targetsList.Items.Refresh();
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            //   Thread.Sleep(10);
        }
    }

As you can see the thread is using Ping 255 times, so it takes time to be finished. 正如您所看到的,线程正在使用Ping 255次,因此需要时间才能完成。 When I press the Stop button apparently the VS2012 Debug Process makes Windows to crush. 当我按下停止按钮时,VS2012调试过程会让Windows崩溃。 Every time that I tried it, Windows crashed. 每次我尝试它,Windows崩溃了。 (My OS: Win7 64Bit) Am I right with this? (我的操作系统:Win7 64Bit)我对吗? And if not, is it fixable? 如果没有,它是否可以修复?

It's a known issue with Visual Studio (since VS2010, apparently) and the Ping class. 这是Visual Studio的一个已知问题 (显然是VS2010)和Ping类。

Posted by Microsoft on 06/02/2012 at 09:11 微软于06/02/2012于09:11发布
Thank you for your feedback. 感谢您的反馈意见。 This is a known issue with the underlying Windows APIs used by the Ping class. 这是Ping类使用的基础Windows API的已知问题。 The Windows team is will determine how to best handle the issue. Windows团队将确定如何最好地处理该问题。

Directly operate UI in the thread will crash.You should use Invoke or BeginInvoke.Invoke is synchronization.BeginInvoke is asynchronization. 在线程中直接操作UI会崩溃。你应该使用Invoke或BeginInvoke.Invoke是synchronization.BeginInvoke是异步。

 this.Invoke(new EventHandler(delegate
        {
            ListBoxItem item = new ListBoxItem();
            item.Content = "192.168.1." + i.ToString();
            targetsList.Items.Add(item);
            targetsList.Items.Refresh();
        }));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM