public MessageGenTask(IReceiver receiver)
 {
     RandomSMS   = new RandomSMS();
     SMSProvider = new SMSProvider(receiver);
     MessageTask = new Task(GenerateMessages);
     MessageTask.Start();
 }
 public MessageGenThread(IReceiver receiver)
 {
     RandomSMS   = new RandomSMS();
     SMSProvider = new SMSProvider(receiver);
     MessageGen  = new Thread(GenerateMessages);
     MessageGen.Start();
 }
 private void GenerateMessages()
 {
     while (true)
     {
         newMessageEvent.WaitOne();
         lock (this) {
             Message = new TextMessage(RandomSMS.RandomName(), RandomSMS.RandomMessage());
             SMSProvider.SendMessage(Message);
             Thread.Sleep(3000);
         }
     }
 }