Need a way to safely exit program

We need a way to detect if a user close or ends our cvi application prematurely.
I can detect if someone kill the application using task manager.  However if my function completes the program does not end..
How do I get my program to continue once the thread is complete?  The below code shows how I am trying to test this.
#include <ansi_c.h>
#include <utility.h>
#include <userint.h>
int CVICALLBACK EventFunctionName (int panelOrMenuBarHandle, int controlOrMenuItemID, int event, void *callbackData, int eventData1, int eventData2)
if (event==EVENT_END_TASK)
if (ConfirmPopup ("Shut Down Detected", "Power to module turned off")!=1)
return -1;
return 0;
int CVICALLBACK InfinateLoop(void *functionData)
int count = 0;
while (1){
printf("Count is: %d\n", count);
Delay(1.0);
count++;
if(count == 5){
return 1;
return 0;
int main(int argc, char *argv[]){
int functionId;
InstallMainCallback (EventFunctionName, 0, 0); //EVENT_END_TASK
CmtScheduleThreadPoolFunction (DEFAULT_THREAD_POOL_HANDLE, InfinateLoop, NULL, &functionId);
RunUserInterface ();

Hey Malcrow,
I'm not exactly sure what you are trying to do.
Are you trying to allow your program to complete once the user tries to end it?  Or are you just trying to detect that a user is closing the program?
If you want the program to finish, you may need to look into swallowing the event.
Here are some links that may help:
Using Callback Functions to Respond to User Interface Events
EVENT_END_TASK
Swallowing Events
Regards,
Jake G.
National Instruments
Applications Engineer

Similar Messages

  • Need a way to inventory Mac programs and corresponding serial numbers

    My boss is a Windows guy & doesn't know what he's doing. Therefore, he insists there's a way out there to inventory all of our office's Macs & generate a list of programs and corresponding serial #s. Is this possible? How?
    In his perfect Microsoft world, this would create an Excel sheet.

    If you've purchased and configured Apple Remote Desktop, then use the Application Usage Report feature -- gives a list of apps and how frequently they are used (in case you want to reigh in licenses).
    A cheap alternative, of course, is to create an admin account on each machine and use 'ssh' to run system_profiler on each machine. e.g. 'system_profiler -detailLevel full SPApplicationsDataType'. You get responses like this (you can request an XML format too):
        Microsoft Word:
          Version: 14.1.2
          Last Modified: 6/15/11 10:05 AM
          Kind: Intel
          64-Bit (Intel): No
          Get Info String: 14.1.2 (110505), © 2010 Microsoft Corporation. All rights reserved.
          Location: /Applications/Microsoft Office 2011/Microsoft Word.app
        TextEdit:
          Version: 1.6
          Last Modified: 6/29/09 9:00 PM
          Kind: Intel
          64-Bit (Intel): Yes
          Location: /Applications/TextEdit.app
        Network Utility:
          Version: 1.4.6
          Last Modified: 6/25/09 5:20 PM
          Kind: Intel
          64-Bit (Intel): Yes
          Get Info String: Version 1.4.6, Copyright © 2000-2009 Apple Inc. All rights reserved.
          Location: /Applications/Utilities/Network Utility.app
        Google Chrome:
          Version: 12.0.742.122
          Last Modified: 7/8/11 8:30 PM
          Kind: Intel
          64-Bit (Intel): No
          Location: /Applications/Google Chrome.app
    ... just a PERL script away from being a spreadsheet.

  • Need a way to stop running programs

    Since the upgrade to os4, I have had to restart my phone almost daily. It seems that when I start an app, it continues to run even after I close it which is great for some apps but others I would rather stop running them when I close them. Is there an app for that?
    Message was edited by: mitch236 to change the os

    http://whenwillapple.com/blog/2010/04/19/iphone-os-4-multitasking-explained-agai n/

  • I need help finding a workable web program that is not CSS based.  I tried IWeb and it just won't work for me.  Way too limiting.  I've been using a 12 year old copy of Macromedia Dreamweaver, but the new Dreamweaver is CSS

    Been building web pages for nearly 20 years, starting with GoLive.  Went to Dreamweaver about 12 years ago, the Macromedia version.  Tried going to iWeb when it came with a new Mac, but found it way too limiting with it's CSS template base.   Unknowlingly, I then bought a new copy of Dreamweaver.   Ooops, Adobe had bought Macromedia and Dreamweaver, too, is now CSS based, which for my money makes it useless to anyone who likes simplicity.   Now I find that even iWeb has been discontinued.  I was told yesterday that Apple doesn't have a web program any more.   At 12 years old, I just don't think it's practical to try to load my old Macromedia Dreamweaver into the new Mountain Lion (I'm getting a new Mac), though it is running, barely, in Snow Leopard.
    I need to find a web builder program that will permit simple construction of educational pages, nothing fancy, nothing artistic, just create a page, give it a color, type or drag in text, insert a table, insert pix in the table blocks, add text under the pix... done!    I should note that I am not looking to build traffic.  I teach simple things for free and people who want to learn those things (antique sewing machine repair, quilting, building longbows) find me.
    I've downloaded trial versions of half a dozen or so programs and looked at maybe 20 more, but all are either CSS based and drive me insane with requirments for constantly making rules and template models, and/or require that you base your web presence in their server.   Also, many will not work with pages built in other programs.  I maintian a volume of over 1000 web pages, many requiring regular updating, and they have been with the same server for more than 15 years.  I'm not about to change.
    So, anybody know a simple, old fashioned web builder that's happpy on a Mac platform?
    Captain Dick

    Although not supported anymore, iWeb does still function using Mountain Lion...
    http://www.iwebformusicians.com/iWeb/mountain-lion.html
    ... and you can purchase it from Amazon.
    Start with a blank page using the Black or WHite template.
    All modern websites use CSS and there are thousands of free templates to be had if you want to use a code entry style application. You will need to go this route if you want to create a site that is viewable on mobile devices although you can create an iPhone version using iWeb...
    http://www.iwebformusicians.com/iWeb/Mobile-iWeb.html
    Search this forum for numerous topics about iWeb alternatives.

  • How to use subroutine in user-exit program

    Hi Experts,
        I have a requirement in user-exit where i have to use some lines of code in several times. So i want to use Perform and perform inside the exit (i.e. Include ZXXX). But it is not recognizing the form part of the ubroutime and gives error.
                 Please let me know how to use the Perform and form statement in the exit or is there any way to  write repeated code once but used no of times in exit program.
    Thanks
    Ajit

    I'm sorry, I was overly harsh there. Please accept my apologies.  But I do despair sometime!
    Consider the structure of a function group and it should be clear - you need to remember that INCLUDES are just repositories of code. If you take the contents out of the include and put them into the main program, then this is what you get:
    function-pool xrsr.        
    * Global data definition.
    function exit_saplrrs0_001.
    * the source code within the zxrsru01 include.
    endfunction.
    Now, what you're trying to do, is create a form in your include. You can't do that, because you end up with:
    function-pool xrsr.        
    * Global data definition.
    function exit_saplrrs0_001.
      perform xyz.
      form xyz.
      endform.
    endfunction.
    And you can't have a FORM defined inside a function module definition. The solution is to put it outside the function module. If you follow the process suggested above, you end up with
    function-pool xrsr.        
    * Global data definition.
    function exit_saplrrs0_001.
      perform xyz.
    endfunction.
    form xyz. " This will be in LXRSRF01
    endform.
    Do you see how it works now?

  • I have installed Adobe Premiere Pro cc on my laptop, but I cant find a way to start the program. No Icon, and it is not showing up in the start meny. It is showing up in add/remove programs, but nt anywhere else.

    I have installed Adobe Premiere Pro cc on my laptop, but I cant find a way to start the program. No Icon, and it is not showing up in the start meny. It is showing up in add/remove programs, but nt anywhere else.

    If you are using a Mac, simply hit Command-Spacebar to bring up Spotlight Search.  Begin typing the name of the application and when you see what you are looking for, press enter.  You should get a hit by the second or third letter you type.  Great way to launch apps on computers that you are not familiar with.
    Windows 7 and 8 should have something similar.  I think you simply press the Windows key and begin typing.  Press enter when you see a match.
    Both Mac and Windows search tools can be customized to search for applications, files, emails and so forth.  For Windows, look for Taskbar and Start Menu Properties.  For Mac, go to Preferences Spotlight.  Turn off items you know you won't need to speed up searches.
    Make Windows 7 Start Menu Search Find Your Applications Faster

  • How to safely uninstall programs in OS X 10.3.9?

    I realize this may be a dumb question, but how do I safely remove programs from my computer? My iBook came with a lot of pre-installed software (such as a now-expired trial version of MS Office) that I don't need, and I would like to free up some disk space. Is it safe to just throw the program in the Trash? I'm used to the complicated world of Windows where you have to use the Add/Remove Programs utility - simply deleting the program seems too "easy" to me.
    Thanks, any help is appreciated!

    Hi Scott,
    Welcome to Apple Discussions
    Here is what Microsoft has to say about uninstalling their Test Drive for 2004. The other thing to do is to search you computer for MS office and delete everything manually, preferences and all. But your best bet is to do what Microsoft says. theXlab has this to say.
    I hope that helps,
    Jon

  • If condition exit program

    i want the user to input two dates, start and end date, in the format (MM/DD/YYYY) how can i add validation so that
    if end date < start date then exit program
    here's a sample
    set verify off
    accept start prompt 'Enter start time'
    accept end prompt 'Enter end time'
    if '&end' < '&start' then
    exit program;
    update table set start_date = '&start', end_date = '&end';
    exit;
    /

    In case of emailing, there is no need to post in forums.
    Coming to your case, I see three possibilites. First As stevencallen suggested, you could easily handle in the update statement itself in the case you presented.
    As you said, you want to know how to exit the program as such, you have two options.
    One, as Chen Shapira suggested, via exception handling, which is another good option of handling user defined exceptions.
    Another, use RETURN keyword and handle your case as well as various other scenarios in which it is applied.
    Any more doubts, please post your requirements completely, so that there is least chance to assume for us and to suggest appriopriately.

  • My up to date iMac can not read the lightroom 5 installation dvd I received for christmas, the dvd player works fine with other dvd's, is there a way to download the program with the dvd's serial number?

    my up to date iMac can not read the lightroom 5 installation dvd I received for christmas, the dvd player works fine with other dvd's, is there a way to download the program with the dvd's serial number?

    No need to worry about the disk version. You would just have to install an update anyway as soon as it was installed. Download from the link provided below and use the serial number you have to activate.
    Product updates

  • I am need to disable an auto start program on my iTunes on my mini Mac

    I am need to disable an auto start program on my iTunes on my mini Mac

    Is there a way to have itunes delete the WMA file after creating mp3 copy?
    No.  But after the MP3s are created and you are satisfied that things went OK, just delete the WMAs manually and say "Good Riddance."
    You can use an MP3 in multiple players, but you need to turn off any features that automatically change or move files, since one player will change something that messes up the other:
    In iTunes, that means go to Edit > Preferences > Advanced and uncheck "Keep..." and "Copy..." 
    In Windows Media Player, that means go to Tools > Options > Library, and uncheck everything that starts with a verb such as "Rename...," "Rearrange...," etc.

  • User Exit Program works Differently

    I'm trying to sync user info from HCM system to a destination system. There is a limitation in SAP HCM system, which allows only full load and not incrememental load or sync up based on events(New Joinee, Position change, Employee Exit) to happen from source to destination. So, I thought User exit could fix this issue.
    When a person inserts or changes or changes the status of an employee to quit through PA30 and saves it, the user exit program should pass the personnel number (numbers) of the user(s) as input to the report RPLDAP_EXTRACT_IDM.
    I am trying to trigger a report(RPLDAP_EXTRACT_IDM) which exports the data from HCM to a destination system(IDM) with the help of a user exit program. Using PA30 when I change the user info and when I save it, through User exit program I'm passing the personnel number of the user(whose data has been changed) as an input to the report, which inturn will replicate the change to the destination.
    Problem:
                User Exit works differently here. After configuring User exit for this tcode(PA30), once I change a user's info and click save, without saving the data, it triggers the User exit program. Usaully while chanign user info, when I click 'SAVE', i get a message 'Recod changed', but now after sonfiguring User Exit program, since the program runs immediately as soon as i click SAVE, I see the following message' Successfully exported Data to the destination' . And the change that i make is not reflected.
    Shouldn't the User Exit program be triggerred after the data is saved?
    Is there a way where I can trigger the User Exit Program after saving the record.

    Not an ABAP expert, but I remember hearing something about PAI and PBO modules and separate user exit includes depending on where you are executing it. Is it worth investigating on these lines?
    Also is it worthwhile configuring Change Pointers to capture whether a change has been made instead of coding user exits in PA30. You could code uxerexits in the ALE data transfer program to analyse the data based on change pointers and transfer data pertaining to New Joinees etc.
    Again I am not ALE epxert, I am just giving my views For what they are worth. For better results perhaps you should post in ABAP forum.

  • Is there another easy way to write this program??

    Hi ,i new in Java Programing,Is there another way to write this program?? This program below is about FIND THE AREA OF A CIRCLE WHEREIN THE RADIUS OF THE CIRCLE RANGES FROM 1 TO 10 BY 1 IN A FOR LOOP.
    import javax.swing.JOptionsPane;
    public class Area2 {
    public static void main(String[] args ) {
    double pi = 3.14;
    int r;
    String a = "Area = ";
    double area;
    for (r = 1; <= 10; r++)
    area = pi * r * r;
    a = a + area + "\n";
    JOptionPane.showMessageDialog(
    null , a);
    System.exit ( 0 );
    I did not write it ,i want to know if is there another way (easy)to write it.
    Thank you very much
    Sincerely Erick.

    Not much to improve upon this. It is a pretty simple program. Note my comment about PI.
    import javax.swing.JOptionsPane;
    public class Area2 {
       public static void main(String[] args ) {
          double final PI = 3.14; // Final because it's a constant value, convention for constants is to use uppercase
         int r;
         String a = "Area = ";
        for  (r = 1; <= 10; r++)
            area  = pi * r * r;
            a = a + area +  "\n";
        JOptionPane.showMessageDialog(null , a);
        System.exit  ( 0 );

  • Just bought refurbished mac, and there's no GarageBand or iMovie and such. I got no disks with the laptop!! Is there any way to get these programs back?

    is there any way to get the programs back??!!??
    if not, are there any good free programs to replace these ones?

    I called Apple Customer Support (1- (800) 767-2775) to check on how much they charge for the gray restore disks that originally came with the MacBook and was quoted $16 dollars per disk plus S & H. Which would be $32 for the two disks. Just give them the serial number of your MacBook and they'll know which ones you need. With the original disks you also get the iLife that was current when your MacBook was bought included on the #2 disk.
    If you only want iPhoto or other single apps from iLife '11 you can get them from the App Store if you're upgraded to 10.6.8. iPhoto, iMovie or Garage Band for $15 each
    Or you can get an iLife DVD on eBay.  http://www.ebay.com/sch/i.html?_trkparms=72%253A1234%257C66%253A2%257C65%253A12% 257C39%253A1&_sacat=0&_sc=1&_nkw=apple%20ilife%2011&_sop=12

  • Why wont the button on my trak pall set to close/exit programs close/exit Firefox 7.0.1?

    I have a Microsoft track ball the 5 customizable buttons.
    The the regular right and left buttons are the default right and left click.
    The outer left button is programed to do the "Enter" function.
    The wheel button is programmed to do the "Back" action.
    The outer right button is programed to "Close/Exit" programs. I have this one set up this was because I do not like tabbed browsing and it makes it easy to close multiple browser windows.
    I just installed 7.0.1, and now the ONLY program that will not close on my system when I press the outer right button is Firefox.
    Can you explain why this is happening?

    Firefox 8 will be released in a few days, that I believe includes fixes for the connections number on Windows, and a problem related to the bookmarks database.
    * meanwhile it may be worth trying the fix from this blog: http://blog.bonardo.net/2011/09/30/is-your-firefor-freezing-at-regular-intervals
    * a more speculative and unofficial suggestion is to adjust the preference ''browser.sessionstore.interval'' as suggested by ''[/questions/767246?page=2#answer-270794 frankal]'' based on http://www.techmynd.com/firefox-freezes-for-a-moment-after-every-10-sec-fix/ <br/>(In my opinion unlikely to do any harm, and easily reversible so worth a try)
    Another suggestion, not as a workaround, but as a means of demonstrating part of the cause is to use the error console to log CC & GC collections. The procedure for changing the preference is as above.
    [http://blog.mozilla.com/nnethercote/2011/10/26/memshrink-progress-week-19/ If you turn on javascript.options.mem.log in about:config you can see when GCs and CCs occur and how long they take, which is helpful for diagnosis.]
    No need to leave that on for long, just look for collections exceeding a second i.e. >1000ms if you see that you have a problem.

  • Is there a way to force a program closed on a Mac Pro?

    Is there a way to force a program to close like you can using the Task Manager in Windows?
    I have Motion 5 that seems to lock up showing the spinning wheel like it thinks like it is doing something in the background.  Unfortunately, It happens when I haven't tried to do anything.  It seems to go on for ever.  The only way I've been able to get out of it if to reboot the computer but I lose all my work in doing so.

    Apple menu > Force Quit...

Maybe you are looking for