Ejemplo n.º 1
0
 public MobilePhoneWithTreadingTasksForm()
 {
     InitializeComponent();
     SimCorpMobileThreadTask = InitSimCorpMobileThreadTask();
     MsgStorage = SimCorpMobileThreadTask.MessageStorage;
     InitSMSNumberComboBox(MsgStorage);
     InitDateTimePickers();
     MsgStorage.MessageAdded   += ShowAddedMessage;
     MsgStorage.MessageDeleted += ShowDeletedMessages;
     //Start background worker
     ChargeBackgroundWorker.RunWorkerAsync();
     //Start charging
     //ChargerThread = new ChargerThread(SimCorpMobile.Battery);
     //ChargerThread.Start();
     ChargerTask = new ChargerTask(SimCorpMobileThreadTask.Battery);
     ChargerTask.Start();
     IsCharging        = true;
     ChargeButton.Text = "Stop charging";
     //Start discharging
     //DischargerThread = new DischargerThread(SimCorpMobile.Battery);
     //DischargerThread.Start();
     DischargerTask = new DischargerTask(SimCorpMobileThreadTask.Battery);
     DischargerTask.Start();
     //Start sending SMS by Thread or by Task
     SimCorpMobileThreadTask.StartGenerateSMS();
 }
Ejemplo n.º 2
0
 private void ChargeBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     while (true)
     {
         // Report progress.
         Thread.Sleep(500);
         ChargeBackgroundWorker.ReportProgress(SimCorpMobileThreadTask.Battery.ChargeLevel);
     }
 }