ROOT not responding

I want to “Start” the data acquisition which could be interrupted at any time the user want.
Also, if the user doesn’t want to interrupt then the system will continue acquiring the data
and will restart after user defined time interval. To test this, I wrote a small code (attached).
When I run this code, the ROOT remains unresponsive for the user defined time, 1 min,
in the example. I want to stop the execution earlier than the pre-defined time by clicking
“Stop” button. But I cannot do it. Could you please help me in this matter?
I have spent 2 days to find out the solution!
Test_Interrupt.cxx (1.85 KB)


The best way is to create a separate thread. Just take a look at your modified macro in attachment (see also the comments in the code).

Cheers, Bertrand.
Test_Interrupt.cxx (2.92 KB)

Hello Bertrand,

Thank you very much for the prompt response, really appreciated.
With the help of your example I have now implemented "Thread"
in my code and it is working as I expected it to work.

Is there any other method which can be used instead of TThread?
I saw some people have suggested using TTimer. If that is possible,
could you please tell me how to use other method?

Thanking you once again.



Hi Ajay,

You’re welcome! And yes, using timers could even be a better solution. Just take a look at the attached macro.

Cheers, Bertrand.
Test_Interrupt2.cxx (2.3 KB)

Hi Bertrand,

Thanks again.

With slight modification I can use the timer example code to run continuously.
But it has to stop by the user. In principle, I want to do somethings like:

Int_t i = 0;
sleep 5m
sleep 30s
i++;}while (i < 5);

How this can be done using TTimer? I have done this using TThread…


Hi Ajay,

Very simple. Here it is.

Cheers, Bertrand.
Test_Interrupt2.cxx (2.53 KB)

Hello Bertrand,

It works great. But only once!
I don’t want to quit root when I click stop instead I just want to stop execution of the loop.
Then when I click Start again, the loop should begin again.



[quote=“ajaydeo”]It works great. But only once!
[/quote]What do you mean? It starts the process, wait for 5minutes, then kill the process, then wait 30 seconds, and start again. It is what you asked for. Now, if you want to be able to start multiple instances, up to you to modify the code to fit exactly what you want.

[quote=“ajaydeo”]I don’t want to quit root when I click stop instead I just want to stop execution of the loop.
[/quote]Then just remove the gApplication->Terminate(0); from the code…

Cheers, Bertrand.

Dear Bertrand,

Thank you much for your help. Now I am able to do what I wanted to do earlier using TTimer.
I am attaching the file with the final version, just for your reference. May be you can suggest
further modifications, if any, would be helpful.


Test_Interrupt3_TT.cxx (4.38 KB)

Hi Ajay,

Maybe just improve a bit the layout (and the behavior when resizing) of your GUI:

[code]void Test_Interrupt3_TT()
iloop = 0;
// main frame
TGMainFrame *fMainFrame = new TGMainFrame(gClient->GetRoot(),200,100);
fMainFrame->SetWindowName(“Test Interrupt”);

// horizontal frame
TGHorizontalFrame *fHFrame = new TGHorizontalFrame(fMainFrame);

fStart = new TGTextButton(fHFrame,“Start”);
start = kFALSE;
fHFrame->AddFrame(fStart, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,2,2,2,2));

TGTextButton *fStop = new TGTextButton(fHFrame,“Exit”);
fHFrame->AddFrame(fStop, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,2,2,2,2));

fMainFrame->AddFrame(fHFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,2,2,2,2));

Cheers, Bertrand.