954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

2 questions: making a program wait, simulating the enter button

Hello,

I am wondering if there is a function in c# that will allow me to wait a certain amount of time before going on to the next procedure?

Also, I was wondering if there is a function that simulates hitting the enter button on the keyboard.

Thanks in advance.

Dark_Omen
Posting Pro
573 posts since Apr 2004
Reputation Points: 23
Solved Threads: 6
 

1. You can insert a timer.
On time event should contain procedure you want to call.

2. On click (on key press) event should do the task.

example:

private void form1_KeyPress(object sender, KeyPessEventArgs e)
{
if (e.KeyChar==13) { // You should insert here code that should be executed // }

}

Abyss
Newbie Poster
5 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

Do you need to make a new thread to use a timer, or can you just say

System.Threading.Timer(5000)


Thanks for the help

Dark_Omen
Posting Pro
573 posts since Apr 2004
Reputation Points: 23
Solved Threads: 6
 

I am not sure for Console Apps, but in Windows Apps you have a component named timer (on WINDOWS FORMS toolbox). you shoud set interval, and in ON TICK event you should insert code.

Abyss
Newbie Poster
5 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

OK, thanks for the help.

Dark_Omen
Posting Pro
573 posts since Apr 2004
Reputation Points: 23
Solved Threads: 6
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You