Click here to Skip to main content
15,914,221 members
Home / Discussions / C#
   

C#

 
GeneralRe: Image.FromFile question Pin
Luc Pattyn27-Dec-07 5:06
sitebuilderLuc Pattyn27-Dec-07 5:06 
GeneralRe: Image.FromFile question Pin
Mike Hankey27-Dec-07 6:31
mveMike Hankey27-Dec-07 6:31 
Jokexxx cranium Pin
Luc Pattyn27-Dec-07 7:13
sitebuilderLuc Pattyn27-Dec-07 7:13 
GeneralRe: Image.FromFile question Pin
KaptinKrunch28-Dec-07 3:48
KaptinKrunch28-Dec-07 3:48 
GeneralRe: Image.FromFile question Pin
Mike Hankey28-Dec-07 4:02
mveMike Hankey28-Dec-07 4:02 
QuestionBinding DataGridView to a Collection. Pin
shehezada26-Dec-07 14:48
shehezada26-Dec-07 14:48 
General.NET serialPort dataReceived Event Help Pin
cmarcus197926-Dec-07 13:54
cmarcus197926-Dec-07 13:54 
GeneralRe: .NET serialPort dataReceived Event Help Pin
Luc Pattyn26-Dec-07 16:34
sitebuilderLuc Pattyn26-Dec-07 16:34 
Hi,


cmarcus1979 wrote:
How do I hold the dataReceived event from firing until the whole message has been received?


AFAIK you can't in general. Serial data comes in over the cable at the rate of the sender.
It gets buffered a couple of times, it gets copied when specific characters are seen,
when a buffer fills, when a timer elapses, whatever; and it will fire your event once
or several times.
If your data exceeds one of the buffer sizes, it most probably will fire multiple times.

In special cases, you can get a single event. Here are some, they all require
cooperation by the other party:

- you implement a question-and-answer system, where the PC asks for data, the other
party sends data while signalling its transmission using one of the control lines
(keep forgetting which is which). Then you can use a PinChanged event instead of
the DataReceived event.

- you append a fixed character to every answer, one that does not appear in the data itself.
Now you can do ReadLine in a separate thread, and have that signal your own event.

- you allow for timing constraints, as in: each answer will take less than T milliseconds
and there will not be more than one conversation in each T milliseconds. Now you can
use DataReceived to start a timer, and the timer elapsing as an event that does the
ReadExisting. (remark: there is a minimum for T, say 33 msec for regular .NET timers;
see my timers article).

On top of all this, you should program defensively, which includes your code should
cope with transmission problems such as sudden disconnects, a lost message, and
a damaged message. This means whatever you implement, at a minimum you must have some
kind of supervisor that resets things when communication comes to a halt.

Hope this helps.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

Happy Holidays!


GeneralRe: .NET serialPort dataReceived Event Help Pin
cmarcus197926-Dec-07 17:00
cmarcus197926-Dec-07 17:00 
Questionhow can i protect my program's in c# Pin
E_Gold26-Dec-07 10:12
E_Gold26-Dec-07 10:12 
AnswerRe: how can i protect my program's in c# Pin
Not Active26-Dec-07 11:22
mentorNot Active26-Dec-07 11:22 
AnswerRe: how can i protect my program's in c# Pin
Paul Conrad26-Dec-07 11:51
professionalPaul Conrad26-Dec-07 11:51 
GeneralRe: how can i protect my program's in c# Pin
E_Gold27-Dec-07 0:16
E_Gold27-Dec-07 0:16 
GeneralRe: how can i protect my program's in c# Pin
Paul Conrad27-Dec-07 5:11
professionalPaul Conrad27-Dec-07 5:11 
QuestionUsing avg function for new constructed column? Pin
omegazafer26-Dec-07 10:10
omegazafer26-Dec-07 10:10 
AnswerRe: Using avg function for new constructed column? Pin
J$26-Dec-07 10:23
J$26-Dec-07 10:23 
GeneralRe: Using avg function for new constructed column? Pin
omegazafer26-Dec-07 11:07
omegazafer26-Dec-07 11:07 
GeneralRe: Using avg function for new constructed column? Pin
omegazafer26-Dec-07 11:19
omegazafer26-Dec-07 11:19 
GeneralCustomizing the property grid.. Pin
slipster21626-Dec-07 9:16
slipster21626-Dec-07 9:16 
GeneralImage surveillance Pin
diddy3426-Dec-07 8:12
diddy3426-Dec-07 8:12 
Generalcross-post Pin
Luc Pattyn26-Dec-07 8:30
sitebuilderLuc Pattyn26-Dec-07 8:30 
GeneralRe: Image surveillance Pin
KaptinKrunch26-Dec-07 8:36
KaptinKrunch26-Dec-07 8:36 
GeneralRe: Image surveillance Pin
Paul Conrad26-Dec-07 9:21
professionalPaul Conrad26-Dec-07 9:21 
Questiongetting Instance of opened form and control manipulation Pin
Adnan Siddiqi26-Dec-07 6:24
Adnan Siddiqi26-Dec-07 6:24 
GeneralRe: getting Instance of opened form and control manipulation Pin
Vikram A Punathambekar26-Dec-07 7:12
Vikram A Punathambekar26-Dec-07 7:12 

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.