.net 4.0 threadpool exception

924 Views Asked by At

the below code throw below exception when compiled with .net 4.0 ,while complied with .net 2.0, it's ok, any guy encounter with me?, please kindly help(I didn't use DateTime in the callback function)。

public void ProcessPriceUpdate()
{
    Interlocked.Increment(ref this.counts);

    lock (contractLock)
    {
        ThreadPool.QueueUserWorkItem(priceCallback, null);
    }
}


>System.ArgumentOutOfRangeException was unhandled
>Message=Value to add was out of range.
>Parameter name: value
>Source=mscorlib
>ParamName=value
>StackTrace:
>at System.DateTime.Add(Double value, Int32 scale)
>at System.Threading.PlatformHelper.get_ProcessorCount()
>at System.Threading.SpinWait.SpinOnce()
>at System.Threading.ThreadPoolWorkQueue.QueueSegment.TryDequeue(IThreadPoolWorkItem& node)
>at System.Threading.ThreadPoolWorkQueue.Dequeue(ThreadPoolWorkQueueThreadLocals tl, IThreadPoolWorkItem& callback, Boolean& missedSteal)
>at System.Threading.ThreadPoolWorkQueue.Dispatch()
>at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
>InnerException:
0

There are 0 best solutions below