Click here to Skip to main content
15,891,033 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: Problem with negative number Pin
K. Ahlers17-Aug-07 0:35
K. Ahlers17-Aug-07 0:35 
GeneralRe: Problem with negative number Pin
Luc Pattyn17-Aug-07 5:43
sitebuilderLuc Pattyn17-Aug-07 5:43 
Question[C#] - How to print a file programmatically... Pin
aravinda77713-Aug-07 23:14
aravinda77713-Aug-07 23:14 
AnswerRe: [C#] - How to print a file programmatically... Pin
Giorgi Dalakishvili13-Aug-07 23:27
mentorGiorgi Dalakishvili13-Aug-07 23:27 
AnswerRe: [C#] - How to print a file programmatically... Pin
Hessam Jalali14-Aug-07 2:09
Hessam Jalali14-Aug-07 2:09 
GeneralRe: [C#] - How to print a file programmatically... Pin
Michael Sync14-Aug-07 21:43
Michael Sync14-Aug-07 21:43 
GeneralRe: [C#] - How to print a file programmatically... Pin
Green Goblin20-Aug-07 9:31
Green Goblin20-Aug-07 9:31 
Questionproblem in calling a dll file Pin
kandy_soliton13-Aug-07 22:47
kandy_soliton13-Aug-07 22:47 
AnswerRe: problem in calling a dll file Pin
Giorgi Dalakishvili13-Aug-07 22:51
mentorGiorgi Dalakishvili13-Aug-07 22:51 
GeneralRe: problem in calling a dll file Pin
kandy_soliton13-Aug-07 23:57
kandy_soliton13-Aug-07 23:57 
GeneralRe: problem in calling a dll file Pin
Giorgi Dalakishvili14-Aug-07 0:01
mentorGiorgi Dalakishvili14-Aug-07 0:01 
GeneralRe: problem in calling a dll file Pin
N a r e s h P a t e l14-Aug-07 0:50
N a r e s h P a t e l14-Aug-07 0:50 
GeneralRe: problem in calling a dll file [modified] Pin
Liam O'Hagan14-Aug-07 19:22
Liam O'Hagan14-Aug-07 19:22 
GeneralRe: problem in calling a dll file Pin
kandy_soliton21-Aug-07 19:35
kandy_soliton21-Aug-07 19:35 
QuestionSlow UI updation problem Pin
getnanda@gmail.com13-Aug-07 22:46
getnanda@gmail.com13-Aug-07 22:46 

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.