TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
athar ansari
NA
8
0
Serial Port Programming
Oct 27 2009 7:43 AM
Hi guys I am new to serial port programming in C#, and I am finding it very difficult. I will be very much thankful in getting any kind of help from u guys. So my problem is: I am not able to find out the way how to detect whether the unit connected to serial port stops sending data. Application should to collect all the data which is coming from the serial port. But i am not able to detect when it is sending data and when it stops. In the application i have written the following code : DateTime dateTimeVariable = DateTime.Parse("01/01/1900"); while (true) { if(dateTimeVariable!=DateTime.Parse("01/01/1900")) { if (DateTime.Now.Subtract(dateTimeVariable).TotalSeconds > 2.1) { serialPort.DataReceived -= serialPort_DataReceived; serialPort.ErrorReceived -= serialPort_ErrorReceived; dateTimeVariable = DateTime.Parse("01/01/1900"); break; } } } dateTimeVariable is actually updated by datarevieved handler. Althought it is working fine but here i have to wait for 2.1 sec everytime even though there is no data in the serial port. Please help me to get the better code.
Reply
Answers (
2
)
Network Sockets
c# question..