Click here to Skip to main content
15,929,584 members
Home / Discussions / C#
   

C#

 
GeneralRe: Using Using object disposal... Pin
Craigpt18-Jul-07 11:48
Craigpt18-Jul-07 11:48 
AnswerRe: Using Using object disposal... Pin
Dave Kreskowiak18-Jul-07 11:48
mveDave Kreskowiak18-Jul-07 11:48 
GeneralRe: Using Using object disposal... Pin
TheTinSoldier18-Jul-07 11:52
TheTinSoldier18-Jul-07 11:52 
GeneralRe: Using Using object disposal... Pin
Scott Dorman18-Jul-07 12:10
professionalScott Dorman18-Jul-07 12:10 
GeneralRe: Using Using object disposal... Pin
TheTinSoldier18-Jul-07 12:53
TheTinSoldier18-Jul-07 12:53 
AnswerRe: Using Using object disposal... Pin
BoneSoft18-Jul-07 12:13
BoneSoft18-Jul-07 12:13 
GeneralRe: Using Using object disposal... Pin
TheTinSoldier18-Jul-07 12:54
TheTinSoldier18-Jul-07 12:54 
AnswerRe: Using Using object disposal... Pin
Luc Pattyn18-Jul-07 12:21
sitebuilderLuc Pattyn18-Jul-07 12:21 
Some comments:

1. you dont need to open a port to know whether it is already open; use the IsOpen property.

2. I would have nested the try and using blocks the other way around, but I dont think
it matters much.

3. I did not find in MSDN doc a statement indicating that Dispose() also calls Close();
lets hope it does. Other classes have either a Dispose() or a Close() method but not
both (of course you could Open() again after Close, not after Dispose).

4. SerialPort.Close (or Dispose?) does not immediately close the port, so when soon followed
by a SerialPort.Open that open may fail (see second remark in MSDN doc on Close).
As a result, while your method name sounds like it is only providing information,
you are actually changing its state (albeit temporarily).

Smile | :)


GeneralRe: Using Using object disposal... Pin
BoneSoft18-Jul-07 12:28
BoneSoft18-Jul-07 12:28 
GeneralRe: Using Using object disposal... Pin
Luc Pattyn18-Jul-07 12:53
sitebuilderLuc Pattyn18-Jul-07 12:53 
GeneralRe: Using Using object disposal... Pin
Ed.Poore18-Jul-07 13:35
Ed.Poore18-Jul-07 13:35 
GeneralRe: Using Using object disposal... Pin
Luc Pattyn18-Jul-07 14:00
sitebuilderLuc Pattyn18-Jul-07 14:00 
GeneralRe: Using Using object disposal... Pin
Ed.Poore18-Jul-07 23:58
Ed.Poore18-Jul-07 23:58 
GeneralRe: Using Using object disposal... Pin
TheTinSoldier18-Jul-07 12:53
TheTinSoldier18-Jul-07 12:53 
GeneralRe: Using Using object disposal... Pin
Luc Pattyn18-Jul-07 13:01
sitebuilderLuc Pattyn18-Jul-07 13:01 
GeneralRe: Using Using object disposal... Pin
TheTinSoldier18-Jul-07 13:08
TheTinSoldier18-Jul-07 13:08 
Questionmap a variable to it's SqlDbType correspondent Pin
Razvan Dimescu18-Jul-07 10:54
Razvan Dimescu18-Jul-07 10:54 
AnswerRe: map a variable to it's SqlDbType correspondent Pin
Ed.Poore18-Jul-07 13:38
Ed.Poore18-Jul-07 13:38 
GeneralRe: map a variable to it's SqlDbType correspondent Pin
Razvan Dimescu18-Jul-07 20:06
Razvan Dimescu18-Jul-07 20:06 
QuestionPopulating data in a form Pin
tthellebuyck18-Jul-07 10:23
tthellebuyck18-Jul-07 10:23 
AnswerRe: Populating data in a form [modified] Pin
TheTinSoldier18-Jul-07 11:26
TheTinSoldier18-Jul-07 11:26 
Questionneed API to send and recieve mail Pin
Mostafa_Ismail18-Jul-07 9:08
Mostafa_Ismail18-Jul-07 9:08 
AnswerRe: need API to send and recieve mail Pin
Dave Kreskowiak18-Jul-07 9:22
mveDave Kreskowiak18-Jul-07 9:22 
GeneralRe: need API to send and recieve mail Pin
Mostafa_Ismail18-Jul-07 9:24
Mostafa_Ismail18-Jul-07 9:24 
QuestionMake a button lose focus Pin
sharpiesharpie18-Jul-07 9:07
sharpiesharpie18-Jul-07 9:07 

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.