How about: // timeout.C void timeout(int sec) { TTimer t(sec*1000, kFALSE); cout << "Start timer for " << sec << " seconds" << endl; while (!t.CheckTimer(gSystem->Now())) gSystem->Sleep(100); // 100 ms sleep cout << "Timed out." << endl; } Cheers, Fons. On Mon, 2003-10-20 at 18:26, Thomas Bretz wrote: > Hi, > > I want to have a simple timeout which I can use a conditional on, like: > > cout << "Start" << endl; > TTimer tm(500, kFALSE); > tm.TurnOn(); > > while (!tm.HasTimedOut()) > usleep(1); > tm.TurnOff(); > cout << "Timed out." << endl; > > I cannot find out how I can realize this using a TTimer which doesn't > depend on the eventloop (asynchronous). > > Maybe somebody can help me? > > Thanks in advance, > Thomas. -- Org: CERN, European Laboratory for Particle Physics. Mail: 1211 Geneve 23, Switzerland E-Mail: Fons.Rademakers@cern.ch Phone: +41 22 7679248 WWW: http://www.rademakers.org/fons/ Fax: +41 22 7679480
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:16 MET