Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to display DTR ON TIME and DTR OFF TIME in listbox in serial port communication that depends on user input, in C#?

like example
1. total time =20 minutes(i/p)Textbox
2. DTR ON=2000 milliseconds(i/p)Textbox
3. DTR OFF =5000 milliseconds (i/p)Textbox
4. start BUTTON
5. LISTBOX(Show the times with message enable/disable)


JUST SEND ME THE C# CODE plsssssssssssssssssss
hey use the thread concept like start sleep start for two threads
Posted
Updated 14-Feb-11 2:08am
v4
Comments
#realJSOP 14-Feb-11 8:20am    
In response to the last sentence in your question - Hey! Just do it yourself. If you have a problem with the code, come back and ask a SPECIFIC question about what you're having a proble with.
nitendrasingh 14-Feb-11 23:32pm    
hey i m fresher man thats y were asking about code just and new with windows so just give the code .

Since DTR is an output from the PC, I would keep a class level Stopwatch instance. Start it when you raise DTR (using the SerialPort.DtrEnable[^] property) and then read the time out in either a timer interrupt or when the user types. Stop it when you lower DTR.

Or have I misread your question?
 
Share this answer
 
To add those strings, herez da codez:

C#
listbox.Items.Add("DTR ON TIME");
listbox.Items.Add("DTR OFF TIME");


Seriously though, are you asking for the time at which DTR was turned on/off?

If so, that would go something like this:

C#
listbox.Items.Add(string.Format("{0} - DTR OFF", DateTime.Now.ToString("yyyyMMdd HH:mm:ss")));
listbox.Items.Add(string.Format("{0} - DTR ON", DateTime.Now.ToString("yyyyMMdd HH:mm:ss")));


Of course, you'd probably have to handle a custom event and invoke the proper delegate in order to add the appropriate text to the listbox, but you didn't ask for code for that, so I assume you know what you're doing.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900