简体   繁体   English

是什么会导致在.NET 4.5下完全正常的代码在3.5以下的情况下变得CPU贪婪呢?

[英]What could cause code that's perfectly fine under .NET 4.5 to be CPU greedy under 3.5?

I'm working with netmq 's latest pre-release and I'm finding the below program will consume virtually no CPU under .NET 4.5 yet is fixed at 13% under version 3.5 of the framework. 我正在使用netmq的最新预发行版,发现以下程序在.NET 4.5下几乎不消耗CPU,但在框架3.5版下固定为13%。

class Program
{
    static void Main(string[] args)
    {
        ThreadPool.QueueUserWorkItem((o) =>
        {
            using (NetMQContext context = NetMQContext.Create())
            {
                using (NetMQSocket requester = context.CreateRequestSocket()) // creating this socket seems to fix cpu consumptio at 13%.. why?
                {
                    Console.WriteLine("LOADED");
                    Console.ReadKey();
                }
                Console.WriteLine("DISPOSED SOCKET");
                Console.ReadKey();
            }
            Console.WriteLine("DISPOSED CONTEXT");
            Console.ReadKey();
        });

        while (true) Thread.Sleep(1000);
    }
}

Does anyone know of a potential reason for this unexpected behaviour? 有人知道这种意外行为的潜在原因吗?

Edit: Confirmed this occurs in .NET 3.5 and does not occur in 4 or 4.5 编辑:确认这发生在.NET 3.5中,并且不在4或4.5中发生

So the problem seems to be that in .Net 3.5 there is a bug with Socket.Select. 因此,问题似乎出在.Net 3.5中,Socket.Select有一个错误。

Socket.Select() with -1 timeout not blocking at all -1超时的Socket.Select()完全没有阻塞

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

相关问题 我可以在.NET 4.5下创建的最大数组是什么? - What is the largest array I can create under .NET 4.5? 在.NET核心下的Linux上运行.NET 4.5 - Running .NET 4.5 on Linux under .NET core 在.NET4.5下使用ArrayList进行转换 - Casting Using ArrayList Under .NET4.5 为什么'任何CPU(更喜欢32位)'允许我在.NET 4.5下分配比x86更多的内存? - Why does 'Any CPU (prefer 32-bit)' allow me to allocate more memory than x86 under .NET 4.5? 在Windows 7下创建新文件和目录时,我的代码是否会导致崩溃? - Could my code cause a crash when creating a new file and directory under Windows 7? 如何获取游标WebKit.Net下的内容 - How to get what's under cursor WebKit.Net 客户端找不到.Net Framework 4.5下的SignalR Hub - SignalR Hub under .Net Framework 4.5 not found by client LuaInterface-在.Net 3.5 / .Net 4.0下编译FileLoadException - LuaInterface - Compiling under .Net 3.5 / .Net 4.0 FileLoadException .NET Framework 3.5与.NET 4.0的并排执行 - Side by Side Execution under .NET Framework 3.5 with .NET 4.0 WPF:两个TabControls /切换在Win7 / .NET 4.5下工作,但在Windows 8.1 / .NET 4.5.1下不工作 - WPF: Two TabControls / Switching works under Win7/.NET 4.5 but not under Windows 8.1/.NET 4.5.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM