Click here to Skip to main content
16,008,942 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
Generalcross-post Pin
Luc Pattyn8-Jan-09 17:47
sitebuilderLuc Pattyn8-Jan-09 17:47 
GeneralRe: cross-post Pin
hrishiS8-Jan-09 18:01
hrishiS8-Jan-09 18:01 
QuestionVB.net or VC++.net for File Copy program Pin
epete11128-Jan-09 16:52
epete11128-Jan-09 16:52 
AnswerRe: VB.net or VC++.net for File Copy program Pin
Not Active8-Jan-09 17:11
mentorNot Active8-Jan-09 17:11 
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 
In my application (VBexpress 2005), I would like to have a process read data from an incoming stream and process it. A blocking read would be fine except that I would like the user to be able to switch between serial ports and TCP connections. It would not be acceptable to simply leave the unused connections open--system requirements dictate that they actually be closed.

Which of the following approaches would be best:
  1. Use a blocking read with a timeout, and figure out some method to get rid of all the 'first chance exception' messages for the timeouts (can anyone tell me how to do that without having to globally disable all first-chance messages)? This would involve some waste of CPU time, but if I use a one-second timeout it wouldn't be too bad; delaying the release of the resource by a second would not be objectionable.

  2. Use a blocking read, and then use .Interrupt on the thread if the port needs to be closed. I'm not sure whether that's guaranteed to work without problems, however.

  3. Use a blocking read, and then rudely close the port in another thread. I think that would probably "usually" cause the read to immediately return a failure, but I don't know that such behavior would be guaranteed.

  4. Use a non-blocking read and close the port while it's pending. I'm not sure whether that would be "safe" either.

  5. Somehow do a read which will wait up to an indicated amount of time (without busy-waiting), but--if no data arrives--will simply return no data rather than throwing an exception. I think I can do this with the TCP ports, but don't see how to do it with serial ports other than busy-waiting.

  6. Something else?

If there were a documented way of telling the system to abandon an asynchronous read operation, that would probably be the ideal method. Unfortunately, I know of no way to do that. I don't want to simply experiment and go with whatever works, because--other than the timeout method--all the approaches rely upon partial thread safety of operations which are not specified as thread-safe. The timeout method is in some ways a little icky, but I'd actually prefer to go with that for simplicity if I could get rid of the annoying "First chance exception" messages. Is there any nice way to do that?

modified on Thursday, January 8, 2009 2:55 PM

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 
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 

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.