Click here to Skip to main content
15,909,039 members
Home / Discussions / C#
   

C#

 
QuestionBlocking Collection Issue Pin
SledgeHammer017-Nov-14 8:24
SledgeHammer017-Nov-14 8:24 
My requirements are simple. I need something with the following:

* queue like behavior (FIFO)
* thread-safe
* blocking behavior for get item method
* blocking get item method should be cancellable (cancellationtoken, bool, etc)
* blocking behavior should be 0% CPU / non spinning (no sleeps)
* high performance

So, naturally, I went with BlockingCollectionT. This works fine, and meets all my requirements, however, when you use the cancellable Take(CancellationToken) and cancel the operation, you get 3 exceptions:

A first chance exception of type 'System.OperationCanceledException' occurred in mscorlib.dll
A first chance exception of type 'System.OperationCanceledException' occurred in mscorlib.dll
A first chance exception of type 'System.OperationCanceledException' occurred in System.dll

The first 2 are caught inside of the framework and the 3rd I catch in my code. This causes people to complain Frown | :( I tried explaining this is "expected behavior", but you know people...

I looked at BlockingCollectionT in ILSpy and it doesn't seem like its going to be possible to bypass the exception throwing. GOD, I hate APIs that throw exceptions for "normal" behavior.

Seems like everything that uses the cancellationtoken throws exceptions on cancellation?

Any other options that don't throw exceptions on a cancellation?
AnswerRe: Blocking Collection Issue Pin
Eddy Vluggen7-Nov-14 9:40
professionalEddy Vluggen7-Nov-14 9:40 
AnswerRe: Blocking Collection Issue Pin
jschell7-Nov-14 12:39
jschell7-Nov-14 12:39 
GeneralRe: Blocking Collection Issue Pin
SledgeHammer017-Nov-14 13:07
SledgeHammer017-Nov-14 13:07 
QuestionHow to calculate matrix determinant? n*n Pin
cicill7-Nov-14 6:18
cicill7-Nov-14 6:18 
AnswerRe: How to calculate matrix determinant? n*n Pin
OriginalGriff7-Nov-14 6:29
mveOriginalGriff7-Nov-14 6:29 
QuestionRe: How to calculate matrix determinant? n*n Pin
ZurdoDev7-Nov-14 10:11
professionalZurdoDev7-Nov-14 10:11 
Question[Howto] C# and DVR media port programming Pin
Benjie Fallar III7-Nov-14 5:26
Benjie Fallar III7-Nov-14 5:26 
GeneralRe: [Howto] C# and DVR media port programming Pin
Eddy Vluggen7-Nov-14 5:42
professionalEddy Vluggen7-Nov-14 5:42 
JokeRe: [Howto] C# and DVR media port programming Pin
PIEBALDconsult7-Nov-14 5:54
mvePIEBALDconsult7-Nov-14 5:54 
GeneralRe: [Howto] C# and DVR media port programming Pin
Benjie Fallar III7-Nov-14 6:00
Benjie Fallar III7-Nov-14 6:00 
GeneralRe: [Howto] C# and DVR media port programming Pin
Benjie Fallar III7-Nov-14 6:00
Benjie Fallar III7-Nov-14 6:00 
GeneralRe: [Howto] C# and DVR media port programming Pin
Eddy Vluggen7-Nov-14 7:24
professionalEddy Vluggen7-Nov-14 7:24 
GeneralRe: [Howto] C# and DVR media port programming Pin
Benjie Fallar III7-Nov-14 19:42
Benjie Fallar III7-Nov-14 19:42 
GeneralRe: [Howto] C# and DVR media port programming Pin
Eddy Vluggen8-Nov-14 3:27
professionalEddy Vluggen8-Nov-14 3:27 
Questionapplication register queries in sql file or in xml files. Pin
Ibrahim.elh6-Nov-14 23:50
Ibrahim.elh6-Nov-14 23:50 
QuestionRe: application register queries in sql file or in xml files. Pin
Eddy Vluggen7-Nov-14 0:26
professionalEddy Vluggen7-Nov-14 0:26 
AnswerRe: application register queries in sql file or in xml files. Pin
Ibrahim.elh7-Nov-14 1:52
Ibrahim.elh7-Nov-14 1:52 
QuestionRe: application register queries in sql file or in xml files. Pin
Eddy Vluggen7-Nov-14 2:58
professionalEddy Vluggen7-Nov-14 2:58 
AnswerRe: application register queries in sql file or in xml files. Pin
Ibrahim.elh7-Nov-14 3:29
Ibrahim.elh7-Nov-14 3:29 
GeneralRe: application register queries in sql file or in xml files. Pin
Eddy Vluggen7-Nov-14 7:27
professionalEddy Vluggen7-Nov-14 7:27 
AnswerRe: application register queries in sql file or in xml files. Pin
PIEBALDconsult7-Nov-14 18:06
mvePIEBALDconsult7-Nov-14 18:06 
GeneralRe: application register queries in sql file or in xml files. Pin
Ibrahim.elh7-Nov-14 21:26
Ibrahim.elh7-Nov-14 21:26 
GeneralRe: application register queries in sql file or in xml files. Pin
Mycroft Holmes7-Nov-14 22:51
professionalMycroft Holmes7-Nov-14 22:51 
QuestionCan we only store Hours and minutes in DateTime Pin
bhausahebshedbale6-Nov-14 16:16
bhausahebshedbale6-Nov-14 16:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.