6 Replies - 1157 Views - Last Post: 10 April 2010 - 09:49 AM Rate Topic: -----

#1 1Timmy  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 35
  • Joined: 25-February 10

pause,wait,how?

Posted 15 March 2010 - 03:06 PM

I am trying to make a program that blinks morse code of what you type.
You type something then press a button,then it starts blinking.To start
I am just working with one letter.It uses a switch to decide what letter
you typed.Then it makes the members of an array either 0,1, or 2. 0 being
a space, 2 being a long, and 1 being a short.I use timers to decide how
long the blink lasts.My problem is:I can't make the program wait until
the timer ticks, so I can start the next one

char letter = textbox1.text;
for (int i = 0;i<1;i++)
{
 switch (letter)
   {
     case 'a':
        a[0] = 0;
        a[1] = 1;
        a[2] = 0;
        a[3] = 2;
        break;
   }

    for (int h = a.length; h < a.length;h++)
    {
     what = a[h]
     switch ( what )
      {
         case 0:
            timer1.enabled = true;
            break;

         case 1:
            timer2.enabled = true;
            break;
   
         case 2:
            timer3.enabled = true; 
      }
    }
}


private void timerA()
{
   picturebox1.backcolor = System.Drawing.color.Greenyellow;
   timer1.enabled = false;
}
private void timerB()
{
   picturebox1.backcolor = System.Drawing.color.empty;
   timer2.enabled = false;
}
private void timerC()
{
   picturebox1.backcolor = System.Drawing.color.empty;
   timer3.enabled = false
}




Is This A Good Question/Topic? 0
  • +

Replies To: pause,wait,how?

#2 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 971
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: pause,wait,how?

Posted 15 March 2010 - 05:02 PM

You want to fire the timers in sequence for each component of each letter. That means each timer event method needs to know both the current letter sequence and an index into that sequence so it can select the next timer to fire: dot, space, or dash.
Was This Post Helpful? 1
  • +
  • -

#3 ssamiev  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 16-March 10

Re: pause,wait,how?

Posted 18 March 2010 - 05:18 AM

Wait and other methods are in System.Threading Namespace
In order to make your app to sleep for a definite seconds u need to write smth like that
Thread.CurrentThread.Sleep(int Milliseconds);

Was This Post Helpful? 1
  • +
  • -

#4 1Timmy  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 35
  • Joined: 25-February 10

Re: pause,wait,how?

Posted 19 March 2010 - 02:09 PM

Since I posted this question I have been working on both ways.It could
take a long time because I do not have much time each day to work on it.

I tried putting the main program on one thread and the timers on another
thread but it is giving me errors like:

" trying to access control not created on the current. "

I will reply back in possibly another week or so.
Was This Post Helpful? 0
  • +
  • -

#5 1Timmy  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 35
  • Joined: 25-February 10

Re: pause,wait,how?

Posted 27 March 2010 - 01:40 PM

Yey!I have made the program work!

Should I ost the code?

I know that we are not supposed to give people the answers outright to anything,so if someone could tell
me wether or not I should,that would be nice.
Was This Post Helpful? 0
  • +
  • -

#6 Sn0wBum  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 9
  • View blog
  • Posts: 178
  • Joined: 04-February 10

Re: pause,wait,how?

Posted 27 March 2010 - 02:39 PM

Yes post your working code... DIC doesn't want people coming in, jacking code an leaving.. this thread shows the learning process and you showing the working code will complete that process :)
Was This Post Helpful? 1
  • +
  • -

#7 1Timmy  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 35
  • Joined: 25-February 10

Re: pause,wait,how?

Posted 10 April 2010 - 09:49 AM

I would love to post the code but my laptop that I wrote it on died.
Right now I am using my grandma's computer. :hammer:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1