<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
<br><br>> To: michael_anonyme@hotmail.com<br>> CC: xorp-hackers@icir.org<br>> Subject: Re: [Xorp-hackers] Timer Event <br>> Date: Wed, 11 Mar 2009 02:07:08 -0700<br>> From: pavlin@ICSI.Berkeley.EDU<br>> <br>> michael anonyme <michael_anonyme@hotmail.com> wrote:<br>> <br>> > <br>> > Hello,<br>> > <br>> > I'm trying to add an event to the EventLoop : <br>> > <br>> > _timeOutVal(TimeVal(10,0)) is initialized in constructor.<br>> > <br>> > I would like that after 10 seconds, Xorp run test_cb method, but it doesn't seems to work.<br>> > <br>> > XorpTimer t = _eventloop.new_oneoff_after(_timeOutVal,callback(this,&ConsensusMain::test_cb));<br>> > <br>> > void ConsensusMain::test_cb() {<br>> > XLOG_INFO("RUN TEST CALLBACK!!!!!\n");<br>> > }<br>> > <br>> > What did I do wrong??<br>> <br>> If the "XorpTime t" object is destroyed (e.g., if it goes out of<br>> scope), then the timer itself on the eventloop is also destroyed.<br>> You need to save it somewhere (e.g., as a private field in the<br>> ConsensusMain class).<br>> <br>> Hope that helps,<br>> Pavlin<br><br>Thanks it works great!!<br><br /><hr />Rejoignez la nouvelle famille de Windows Live Messenger <a href='http://download.live.com' target='_new'>Cliquez ici!</a></body>
</html>