Click here to Skip to main content
15,902,938 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestiondBase field called "Value" cannot be edited Pin
bobbymale778-Jan-09 16:16
bobbymale778-Jan-09 16:16 
AnswerRe: dBase field called "Value" cannot be edited Pin
moon_stick8-Jan-09 23:02
moon_stick8-Jan-09 23:02 
GeneralRe: dBase field called "Value" cannot be edited Pin
bobbymale779-Jan-09 12:59
bobbymale779-Jan-09 12:59 
QuestionClean way to have an abortable read for serial or TCP stream? Pin
supercat98-Jan-09 8:29
supercat98-Jan-09 8:29 
AnswerRe: Clean way to have an abortable read for serial or TCP stream? Pin
Mark Churchill8-Jan-09 11:08
Mark Churchill8-Jan-09 11:08 
GeneralRe: Clean way to have an abortable read for serial or TCP stream? Pin
supercat98-Jan-09 13:04
supercat98-Jan-09 13:04 
GeneralRe: Clean way to have an abortable read for serial or TCP stream? Pin
Colin Angus Mackay8-Jan-09 13:17
Colin Angus Mackay8-Jan-09 13:17 
GeneralRe: Clean way to have an abortable read for serial or TCP stream? [modified] Pin
supercat98-Jan-09 14:16
supercat98-Jan-09 14:16 
I did finally figure out a way to make the serial port work reasonably, using a received-data event to hit a ManualResetEvent (if the main communication thread has set it). The code creates a new ManualResetEvent every time the main thread polls and there isn't any data available; a monitor might be better, but using the ManaulResetEvent makes it possible for another thread to set a 'hurry up and abort the current operation' WaitHandle (which could be used, along with the former, in a WaitAny).

Okay - I feel that is an unfair comment.


Since there seems to be a good solution using events, I'd agree that my apparent antipathy toward the authors of the SerialPort class was somewhat misplaced. The Windows communications API has somewhat dubious semantics (which probably go back aeons) and the SerialPort class is mostly just exposing them. The decision to have a timeout error always throw an exception is unfortunate, but the availability of the receive data event makes it possible to emulate the two styles of semantics that a good communications library should support:

-1- Wait up to a specified time for 'n' bytes; if fewer than 'n' bytes become available in time, do not return a smaller number, but instead flag an error (or throw an exception).

-2- If any data is available, return it. Otherwise, wait up to a specified amount of time (possibly zero) to see if any arrives.

The Windows API is a mishmosh of these approaches, so I suppose it makes sense that the SerialPort class would be as well.

Colin Angus Mackay wrote:
Do you wait until you have an absolutely perfect product before going to market, or do you go to market earlier with a product that will satisfy most people?


Maybe I was a bit too sarcastic, but to my mind the concept of a 'try' pattern should be a core part of any non-trivial exception-based code, except in circumstances where it's not practical to predict an operation's success without committing to the operation. Whoever made the first-chance exceptions go to the immediate window was clearly trying to encourage programmers to avoid exceptions when practical; a worthy goal, but one which requires giving programmers the tools to do that.

I guess what I find most irksome/puzzling about things like Date.Parse is that I can't imagine that people could use such a function very much without its limitations quickly becoming apparent. If Microsoft had to code around the limitations of something like Date.Parse in order to make its other products work, that would suggest that such workarounds should perhaps have been included in the .net framework in the first place.

Yes, there's a lot more to Windows and .net than meets the eye, but I doubt I'm the only person to stumble upon some of the annoyances.

modified on Thursday, January 8, 2009 10:28 PM

QuestionHow to get the %of cpu usage using WMI Pin
S.Rekka8-Jan-09 1:37
S.Rekka8-Jan-09 1:37 
AnswerRe: How to get the %of cpu usage using WMI Pin
Mark Salsbery8-Jan-09 6:09
Mark Salsbery8-Jan-09 6:09 
GeneralRe: How to get the %of cpu usage using WMI Pin
S.Rekka8-Jan-09 18:12
S.Rekka8-Jan-09 18:12 
QuestionCalling an exe from init() method Pin
ajayvictor0077-Jan-09 23:02
ajayvictor0077-Jan-09 23:02 
AnswerRe: Calling an exe from init() method Pin
Brij8-Jan-09 1:53
mentorBrij8-Jan-09 1:53 
QuestionSCSF & "neutral culture assembly exception" [modified] Pin
A_Fisher7-Jan-09 21:59
A_Fisher7-Jan-09 21:59 
AnswerRe: SCSF & "neutral culture assembly exception" Pin
Shaun Wilde8-Jan-09 8:43
Shaun Wilde8-Jan-09 8:43 
QuestionImages not appearing in delivered mail Pin
Vivek Bhatnagar7-Jan-09 21:23
Vivek Bhatnagar7-Jan-09 21:23 
AnswerRe: Images not appearing in delivered mail Pin
Not Active8-Jan-09 3:48
mentorNot Active8-Jan-09 3:48 
GeneralKinda OT / maybe a little dumb: Images not appearing in delivered mail Pin
EliottA8-Jan-09 4:38
EliottA8-Jan-09 4:38 
GeneralRe: Kinda OT / maybe a little dumb: Images not appearing in delivered mail Pin
Not Active8-Jan-09 5:18
mentorNot Active8-Jan-09 5:18 
GeneralRe: Kinda OT / maybe a little dumb: Images not appearing in delivered mail Pin
EliottA8-Jan-09 5:29
EliottA8-Jan-09 5:29 
AnswerRe: Images not appearing in delivered mail Pin
Aman Bhullar8-Jan-09 6:11
Aman Bhullar8-Jan-09 6:11 
GeneralRe: Images not appearing in delivered mail Pin
EliottA8-Jan-09 6:32
EliottA8-Jan-09 6:32 
GeneralRe: Images not appearing in delivered mail Pin
Vivek Bhatnagar8-Jan-09 18:45
Vivek Bhatnagar8-Jan-09 18:45 
GeneralRe: Images not appearing in delivered mail Pin
Aman Bhullar9-Jan-09 4:44
Aman Bhullar9-Jan-09 4:44 
AnswerRe: Images not appearing in delivered mail Pin
Vivek Bhatnagar8-Jan-09 18:38
Vivek Bhatnagar8-Jan-09 18:38 

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.