Click here to Skip to main content
15,900,511 members
Home / Discussions / C#
   

C#

 
QuestionBest way to implement a wrapper class with files Pin
Christopher Stratmann14-Aug-07 2:29
Christopher Stratmann14-Aug-07 2:29 
AnswerRe: Best way to implement a wrapper class with files Pin
Colin Angus Mackay14-Aug-07 2:56
Colin Angus Mackay14-Aug-07 2:56 
GeneralRe: Best way to implement a wrapper class with files Pin
Christopher Stratmann14-Aug-07 3:23
Christopher Stratmann14-Aug-07 3:23 
QuestionSTA model and new thread Pin
myshketer14-Aug-07 1:38
myshketer14-Aug-07 1:38 
AnswerRe: STA model and new thread Pin
Judah Gabriel Himango14-Aug-07 4:12
sponsorJudah Gabriel Himango14-Aug-07 4:12 
QuestionIPropertyStorage.ReadMultiple problem Pin
C_Man14-Aug-07 1:31
C_Man14-Aug-07 1:31 
AnswerRe: IPropertyStorage.ReadMultiple problem Pin
Judah Gabriel Himango14-Aug-07 4:13
sponsorJudah Gabriel Himango14-Aug-07 4:13 
GeneralRe: IPropertyStorage.ReadMultiple problem Pin
C_Man14-Aug-07 5:13
C_Man14-Aug-07 5:13 
Questionconvert html to pdf Pin
omer erakman14-Aug-07 1:23
omer erakman14-Aug-07 1:23 
AnswerRe: convert html to pdf Pin
Hessam Jalali14-Aug-07 2:50
Hessam Jalali14-Aug-07 2:50 
AnswerRe: convert html to pdf Pin
Vasudevan Deepak Kumar14-Aug-07 4:10
Vasudevan Deepak Kumar14-Aug-07 4:10 
GeneralRe: convert html to pdf Pin
omer erakman14-Aug-07 4:20
omer erakman14-Aug-07 4:20 
QuestionProblem with negative number Pin
K. Ahlers14-Aug-07 1:19
K. Ahlers14-Aug-07 1:19 
AnswerRe: Problem with negative number Pin
plastio14-Aug-07 1:37
plastio14-Aug-07 1:37 
GeneralRe: Problem with negative number Pin
K. Ahlers14-Aug-07 1:40
K. Ahlers14-Aug-07 1:40 
AnswerRe: Problem with negative number Pin
Luc Pattyn14-Aug-07 1:42
sitebuilderLuc Pattyn14-Aug-07 1:42 
GeneralRe: Problem with negative number Pin
K. Ahlers14-Aug-07 1:45
K. Ahlers14-Aug-07 1:45 
GeneralRe: Problem with negative number Pin
J4amieC14-Aug-07 3:24
J4amieC14-Aug-07 3:24 
GeneralRe: Problem with negative number Pin
Luc Pattyn14-Aug-07 6:06
sitebuilderLuc Pattyn14-Aug-07 6:06 
GeneralRe: Problem with negative number Pin
K. Ahlers14-Aug-07 10:57
K. Ahlers14-Aug-07 10:57 
GeneralRe: Problem with negative number Pin
Luc Pattyn14-Aug-07 13:31
sitebuilderLuc Pattyn14-Aug-07 13:31 
GeneralRe: Problem with negative number Pin
K. Ahlers14-Aug-07 23:14
K. Ahlers14-Aug-07 23:14 
GeneralRe: Problem with negative number Pin
Luc Pattyn15-Aug-07 2:43
sitebuilderLuc Pattyn15-Aug-07 2:43 
Hi,

I looked at your code and have some comments:

1.
you did not follow my advice "put a try-catch and have it show all relevant variables
when it catches this or some other exception, including cmd, tmp, ..."

2.
I don't see why you have the test in
if(posofbreak < _buffer.Length - 1) _buffer = _buffer.Substring(posofbreak + 1);

With it, if _buffer contains just one line ending on \n, that line remains in
_buffer and will be processed again next time DataReceived fires.

3.
while(tmp.IndexOf('>') > -1) tmp = tmp.Substring(tmp.IndexOf('>') + 1).Trim();
could have been handled more elegantly with ListIndexOf

4.
I am not sure the Thread.Sleeps, especially the one with 2000, are a good idea
inside DataReceived; they make your code not react for 2 seconds on the next
data; if for some reason "L67 2\n" comes in every second, you will never
catch up.

5.
I don't know what value serialport1.ReceivedBytesThreshold has; if it is
much larger than 1, chances are you receive more than one line of text every
time, but you only process one line at a time.
Actually, there should have been a while loop: as long as entire lines are
available, process it.

6.
if buffer contains only one line of the form
sometext > \n
then tmp will be an empty string; not sure SQL will like that

I strongly suggest you follow my advice (see 1); I don't understand how you
did not do this from the beginning: when something goes wrong, the more information
you have about it, the easier it is to pinpoint the problem...

Hope this helps.






Luc Pattyn [Forum Guidelines] [My Articles]


this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google


GeneralRe: Problem with negative number Pin
K. Ahlers15-Aug-07 3:29
K. Ahlers15-Aug-07 3:29 
GeneralRe: Problem with negative number Pin
Luc Pattyn15-Aug-07 3:57
sitebuilderLuc Pattyn15-Aug-07 3:57 

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.