[英]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.