Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataReceived Event
Message
From
29/04/2009 14:11:14
 
 
To
All
General information
Forum:
ASP.NET
Category:
Forms
Title:
DataReceived Event
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Application:
Desktop
Miscellaneous
Thread ID:
01397031
Message ID:
01397031
Views:
120
I have the following data received event handler for serial communications. My com port object has a ReceivedBytesThreshold set to 18. The problem I have is the data coming into the com port ranges from 8 bytes to 160 bytes and I don't always get the entire message. Whenever I step through in debug mode all bytes are captureed in the buffer. Is there a way to delay the event from firing until all bytes are received., without having to constantly create an instance of the serial port and change the ReceivedBytesThreshold?
        private void comm_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            int bytes = comm.BytesToRead;
            commBuffer = new byte[bytes];
            comm.Read(commBuffer, 0, bytes);
            //fire the newMessage event
            newMessage(commBuffer, NewMessageEventArgs.messageType.Status);                            
Reply
Map
View

Click here to load this message in the networking platform