System.Timers

Discussion about the open-source Phalanger [?] project.

System.Timers

Postby z668 » June 20th, 2013, 7:45 pm

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?
z668
 
Posts: 6
Joined: March 25th, 2013, 9:38 pm

Re: System.Timers

Postby Jakub Misek » June 23rd, 2013, 2:48 pm

What does it say in your Errors Window, or Output Window?

Thanks
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: System.Timers

Postby z668 » June 24th, 2013, 5:18 am

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
z668
 
Posts: 6
Joined: March 25th, 2013, 9:38 pm

Re: System.Timers

Postby Jakub Misek » June 24th, 2013, 4:10 pm

"$tim::$Elapsed" means access to static property Elapsed on class name {$tim}.

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

Thanks,
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: System.Timers

Postby z668 » June 26th, 2013, 5:18 am

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!
z668
 
Posts: 6
Joined: March 25th, 2013, 9:38 pm


Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 1 guest

cron

User Control Panel

Login

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 124 on September 25th, 2020, 6:57 am

Users browsing this forum: No registered users and 1 guest