NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
HansiWWW
Posts: 22
0 Kudos

Interrupt running process

Hi,

 

I have a command button, which starts a long calculation process (signal computation, several graph updates, etc.). During the process everything is block in the GUI. Now I would like to add another button (or additional feature to the same button) to stop the running calcutation/visualization progress...

 

How can I manage that?

 

Cheers

Active Participant
Wolfgang
Posts: 1,929
0 Kudos

Re: Interrupt running process

  • Don't dim (block) the Stop button
  • Avoid time-consuming callbacks because they lock out UI operation or add some calls to ProcessSystemEvents ()
Member
HansiWWW
Posts: 22
0 Kudos

Re: Interrupt running process

Its wanted that the processing takes so much time...

 

The only thing I would like to add is a kind of interrupt feature:

 

Button X has two functionalities:

- starting thread 1 with multiple calculations and visualizations

- if thread 1 is running, interrupting this thread again

Active Participant
Wolfgang
Posts: 1,929
0 Kudos

Re: Interrupt running process

[ Edited ]

I did not suggest to shorten the processing time, only the callback :smileywink:

 

So the suggestion would be to have your button callback as follows:

 

if ( event == EVENT_COMMIT )
{

    status != status;

    if ( status )

    {

//  start thread 

    }

    else

    {

//    stop thread

    }

}

 

This way your main (GUI) thread can react on user events, see also SetSleepPolicy and the multithreading examples provided by CVI.

 

I think that you actually do not even need to start and stop the thread in the callback, if your visualization thread (launched ahead) checks the status variable

Member
KyleP
Posts: 129
0 Kudos

Re: Interrupt running process

Hi HansiWWW,

 

I think what you're looking for is ProcessSystemEvents.

 

Cheers,

KyleP
Applications Engineer
National Instruments
Member
HansiWWW
Posts: 22
0 Kudos

Re: Interrupt running process

I did it like Wolfgang and KyleP said... It works fine... Thanks guys...

Active Participant
Wolfgang
Posts: 1,929

Re: Interrupt running process

...if your question got resolved, you could mark the answer as the solution... :smileyhappy: When searching the forum solved threads are better than threads that are still open

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page