Page 1 of 1

System.Timers

PostPosted: June 20th, 2013, 7:45 pm
by z668
Hello!

Code: Select all
private function tmr(\System\Object $sender, \System\Timers\ElapsedEventArgs $e)
            {
                $this->richTextBox1->Text .= "test\r\n";
            }
           
            private function button1_Click(\System\Object $sender, \System\EventArgs $e) {
               
                $tim = new \System\Timers\Timer();
                $tim->Elapsed += new \System\Timers\ElapsedEventHandler($this->tmr);
                $tim->Interval = 1000;
                $tim->Start();
            }


What's the error?

Re: System.Timers

PostPosted: June 23rd, 2013, 2:48 pm
by Jakub Misek
What does it say in your Errors Window, or Output Window?

Thanks

Re: System.Timers

PostPosted: June 24th, 2013, 5:18 am
by z668
Jakub Misek wrote:What does it say in your Errors Window, or Output Window?

Thanks


Cannot write to event System\Timers\Timer::$Elapsed, use System\Timers\Timer::$Elapsed->Add() and System\Timers\Timer::$Elapsed->Remove() to add or remove an event handler


or

Code: Select all
$tim = new \System\Timers\Timer();
      $tim->$Elapsed->Add($this->tmr);
      $tim->Interval = 1000;
      $tim->Start();


Call to a member function Add() on a non-object


or

Code: Select all
$tim = new \System\Timers\Timer();
      $tim::$Elapsed->Add($this->tmr);
      $tim->Interval = 1000;
      $tim->Start();


Access to undeclared static property: System\Timers\Timer::$Elapsed

Re: System.Timers

PostPosted: June 24th, 2013, 4:10 pm
by Jakub Misek
"$tim::$Elapsed" means access to static property Elapsed on class name {$tim}.

Use "$tim::Elapsed" instead. That should fix your problem.

Thanks,

Re: System.Timers

PostPosted: June 26th, 2013, 5:18 am
by z668
Jakub Misek wrote:"$tim::$Elapsed" means access to static property Elapsed on class name {$tim}.

Use "$tim::Elapsed" instead. That should fix your problem.

Thanks,

Thank you!