Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DataReceived Event
Message
De
29/04/2009 14:11:14
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Titre:
DataReceived Event
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Application:
Desktop
Divers
Thread ID:
01397031
Message ID:
01397031
Vues:
121
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);                            
Répondre
Fil
Voir

Click here to load this message in the networking platform