How to exit properly ChangeDetection thread?

I call the function ChangeDetection of the NI USB-6525 with C in a C++ program code:

DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateDIChan (taskHandle, "Dev1/port1/$line0", "", DAQmx_Val_ChanPerLine));
DAQmxErrChk (DAQmxCfgChangeDetectionTiming(taskHandle,"Dev1/port1/line0","Dev1/port1/line0",DAQmx_Val_FiniteSamps,1));
DAQmxErrChk (DAQmxRegisterSignalEvent(taskHandle,DAQmx_Val_ChangeDetectionEvent,0,ChangeDetectionCallback,));
DAQmxErrChk (DAQmxGetTaskNumChans (taskHandle, & numLines));

DAQmxErrChk (DAQmxStartTask (taskHandle));

As far as I understand, this creates a separate thread that defines the USB box - 6525 ChangeDetection mode. When the unit detects a signal change, the C++ program calls a function (called ChangeDetectionCallback() in this case), which runs in its own thread (or perhaps the same thread, but in any case not the thread used to call the above code). It is explained here and is due to the argument of '0' in DAQmxRegisterSignalEvent().

What I want to know is: while this thread is running (either one created by one of the above functions or whoever runs ChangeDetectionCallback() in), it is ok to quit the program? It could be any problem resulting from resources unfreed, for example? Are there measures should I take to make sure that everything completes successfully, as making sure always to call DAQmxStopTask() and DAQmxClearTask() before you quit the program?

Hello

If you click Exit, you must release all resources and the sons who have served in your program.

You mentioned the right features, if you work with DAQmx, you must stop and cancel the task. If you work with threads (Thread Safe queue for example), it must be released, too. If you opened the file for playback of /writing, you must close them to provide the means and the free memory again.

brinmr wrote:

I call the function ChangeDetection of the NI USB-6525 with C in a C++ program code:

DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateDIChan (taskHandle, "Dev1/port1/$line0", "", DAQmx_Val_ChanPerLine));
DAQmxErrChk (DAQmxCfgChangeDetectionTiming(taskHandle,"Dev1/port1/line0","Dev1/port1/line0",DAQmx_Val_FiniteSamps,1));
DAQmxErrChk (DAQmxRegisterSignalEvent(taskHandle,DAQmx_Val_ChangeDetectionEvent,0,ChangeDetectionCallback,));
DAQmxErrChk (DAQmxGetTaskNumChans (taskHandle, & numLines));

DAQmxErrChk (DAQmxStartTask (taskHandle));

As far as I understand, this creates a separate thread that defines the USB box - 6525 ChangeDetection mode. When the unit detects a signal change, the C++ program calls a function (called ChangeDetectionCallback() in this case), which runs in its own thread (or perhaps the same thread, but in any case not the thread used to call the above code). It is explained here and is due to the argument of '0' in DAQmxRegisterSignalEvent().

What I want to know is: while this thread is running (either one created by one of the above functions or whoever runs ChangeDetectionCallback() in), it is ok to quit the program? It could be any problem resulting from resources unfreed, for example? Are there measures should I take to make sure that everything completes successfully, as making sure always to call DAQmxStopTask() and DAQmxClearTask() before you quit the program?

Best regards, Fabian

Tags: NI Hardware

Similar Questions

  • How to disable the hyper-thread on U840 Satellite Ultrabook?

    I would like to know how to turn off hyper-thread on Ultrabook U840

    Does anyone have any suggestions?

    Thanks in advance for your suggestions :>

    Model Toshiba U840
    Processor number: i5-3317U
    http://Ark.Intel.com/products/65707

    Something like that is controlled by the BIOS and if that option exists, you might find in the BIOS settings.
    However, if its not available in the BIOS, you would be able to disable s Intel Hyper - Threading Technology

  • How to remove properly/completely freeware?

    How can I properly/completely remove bloatware FREEWARE I don't see in Add/Remove programs... for example AOL additional software to install, Fifa Demo, etc.?

    Thank you for your time.

    PS: this is the first time that I've never used a forum please let me know of any errors.

    Then check the properties of each freeware and you will find the right path. When you know where the freeware, remove it manually.

  • How to exit safe mode in windows 8.1

    I entered in the Mode without fail my desire TS 15 running windows 8.1 to correct some problems with my Norton software and now I can't understand how to exit back to the normal mode.  Internet is off in safe mode (even though I chose the mode safe mode with networking) so I can run any of the resolutions & assistance.  Someone knows how to do this?

    Nanna,

    Welcome to the HP Forum.

    Try / review

    Control Panel > display icon > Administrative Tools> System Configuration >

    Boot Tab > UNCHECKstartup

    Restart/ reboot the computer and log in

    OR

    A different path to the same place:

    ·         Start Notepad and let it boot mode safe

    ·         Open a session

    ·         Windows key + R(open the run window)

    ·         Type msconfig

    ·         Opens the System Configuration Menu > tab click on Boot

    ·         REMOVE the check mark next to startup > Applyto save

    ·         Restart/ reboot

    ==========================================================================

    In addition, you could do your router security is set to

    AES encryption type

    and

    WPA2-Personal security type

    ==========================================================================

    For later, it's very useful to have, and it is easy to set up.  I did it.

    Safe mode can easily be added to the start screen.

    How to add 'Safe Mode' to the Windows in Windows 8 boot manager and 8.1

    From:
    Features of Windows 8 - a Quick Tour

    Click on the Thumbs-Up Kudosto testify and say thank you.

    While I strive to reflect best practices of HP, I do not work for HP.

  • How to exit safe mode?

    How to exit safe mode. New for this survey

    Original title: Mr. raymond scott

    From Internet Explorer

    Hello

    If does not restart the computer in normal mode (not sure) try this...

    Start > run (or Windows key + r), type msconfig, and then press ENTER.

    On the general tab, select Normal startup, click OK, and then restart.

    Don

  • How do I delete a thread?

    How do I delete a thread?

    Published by: 987267 on 10 February 2013 20:37

    You can not. MODs can.

    Valuable lesson. Do not post what you cannot delete. ;-)

    What you can do is to click on the button to edit and delete the contents of your ad. However, which affects no other responses, or remove pieces from your original assignment that they cited in their responses.

  • How to exit the camera application properly

    I start the camera application by doing this

    Invoke.invokeApplication (Invoke.APP_TYPE_CAMERA, new CameraArguments());

    The camera app starts. I take a picture.

    I am on a 9000 "BOLD".

    You use the camera you will find that you can not close the app until you get rid of the image sets that you have just taken.

    For example
    take photo

    Picture is a static view of the screen

    If you press close (close menu) it does ' t go away.

    If you press the ESC key, then press close he disappears.

    now in my application, I need to simulate this but I can't seem to get out

    I want to launch the application.

    Press the trackball to take the picture

    Save the photo.

    Then exit.

    I inject

    EventInjector.invokeEvent (new EventInjector.KeyEvent (EventInjector.KeyEvent.KEY_DOWN, Characters.ESCAPE, 10));

    EventInjector.invokeEvent (new EventInjector.KeyEvent (EventInjector.KeyEvent.KEY_UP, Characters.ESCAPE, 30));

    And it closes ok

    BUT... when I opened the camera (for the second time) the image is on the screen, the last shot.

    So, it didn't really come out. The user must press the ESC key stupid and then take another picture.

    Any ideas?

    Thank you

    You test this in the simulator of BlackBerry or on a real BlackBerry "BOLD"?  What version of BlackBerry device software you are using (beneath Options, about)?  Is that you inject events for all the actions in your list or just the ESC key to exit?

  • How should I interpret java thread dumps?

    I have a multi-threaded application, I am running on a BlackBerry 9000.  I suspect there are blocking issues.

    I figured out how to trigger the trace of the stack using javaloader - usb logstacktraces (rather than wait for the alert for error "not responding") and can fetch using javaloader - usb eventlog, but I cannot interpret them.

    When I develop java applications normal can I use ^-to get a thread dump containing the source files, line numbers, and (most importantly) a list of locks and blocks, telling me that has a lock on an object, and which is blocked waiting for a lock to be released (either by calling the wait() method or exit).

    I don't know if this information is in the Blackberry stack traces.

    guid:0x9C3CD62E3320B498 time: Thu Sep 10 15:51:37 2009  severity:0 type:3 app:Java Exception data:
        ForcedStackTraceException
        baconology(160) 33 2 0x482E4000
        baconology(4AA957F5)
         BlockRun
         nap
         0x3EF
        baconology(4AA957F5)
         BlockRun
         waitForBuffer
         0x4BF
        baconology(4AA957F5)
         PiecewiseSourceStream
         read_
         0x14D7
        baconology(4AA957F5)
         PiecewiseSourceStream
         read
         0x1570
        net_rim_cldc-16(4A739706)
         DataSourceInputStream
         read
         0x25AF
        net_rim_media(4A739765)
         MP4Info
         
         0x34E1
        net_rim_media(4A739765)
         MP4Info
         
         0x2DA7
        net_rim_media(4A739765)
         MP4Info
         
         0x2D63
        net_rim_media(4A739765)
         MP4Info
         
         0x33A8
        net_rim_media(4A739765)
         StreamingMediaPlayer
         doRealize
         0x9224
        net_rim_cldc-16(4A739706)
         BasicPlayerImpl
         realize
         0xF80
        baconology(4AA957F5)
         JMFToy
         fabricateAndRealizePlayer
         0x9F5
        baconology(4AA957F5)
         JMFToy$3
         run
         0xD94
        net_rim_cldc-1(4A739706)
         Thread
         run
    

    Given that this thread is blocked waiting to enter the BlockRun.nap () call, I can assume that it is blocked, waiting for a lock on * this *, because otherwise it would be inside the Object.wait () function, waiting for another thread to issue a notifyAll().

    What I need to know is the thread that has the lock, so I can arrange for to be released or not granted at all.

    Each (single-threaded) stack trace begins with the name of the process that owns the thread, followed by the ID process in parentheses, then by the thread ID, then the State of the thread (1 = RUNNABLE, 2 = pending, 3 = TIMED WAITING, 4 = BLOCKED), then the ID of the lock on which thread executes a wait(), or the ID of the lock, the thread is stuck on (waiting to acquire).

    After the stack traces there is a list of the locks. The list shows which own threads which locks and locks Java class names.

    The information contained in the stack traces and the list of locks is sufficient for an automated tool to analyze the dependencies between threads and also find dead-locks (as appropriate). I depeloped such a tool (thus, it is possible, and it's not hard to do), but I'm not free to release him.

  • Please tell us how to remove the 'message thread function' in the column 'Object' of my Inbox.

    Hello!
    For some reason, the column of the object on the Inbox of my e-mail account now has the topics of conversation. I have no idea how the son got there - and you would appreciate the help in eliminating these threads.
    Thanks a lot for your help.

    In the main menu bar:
    View (Alt - V) - sort by - Unthreaded

  • AT300 - how to exit safe mode?

    My tablet to 300 went into safe mode.
    1: how to get out safe mode
    2: What safe mode made for my Tablet

    A big thank you to all those who can help you

    Dave

    Hello

    You can start the Android device in safe mode to troubleshoot your device.
    For example, if you are affected by plant, crashes or problems of battery life, you can boot into safe mode and see if the problems still occur there. Safe mode, you can uninstall misbehaving third-party applications.

    To exit safe mode, press the power button, select turn off and restart your machine in normal mode

  • How to exit while loop with delay schedule?

    I have a pretty heavy program that iteratively takes a series of measures from a number of channels using a variety OR-Switch and OR-DMM screws that I assembled as a result of various examples and several help pages. Each channel is sampled once during each iteration with data to be saved in a text file for later analysis, after it is imported into Excel. I added to the screen 'real time' indicators and charts to see what looks like running data.

    Each iteration is performed using a While loop with a delay timer, even if a previous version, I used a timed loop. Measures for the series of channels are collected with a loop For inside the While loop. The loop For includes screws which:

    1 cut the channel and wait as debounce.

    2 Initializes the DMM and passes the configuration information.

    3. wait for a while to make sure that the DMM is set.

    4. measure.

    5. close the DMM.

    6 disconnect all the switches.

    The terms of the election of the channels is ends in 15-20 seconds and I am currently collecting data every two minutes, so he spends "wait" time "collection". Each iteration of the loop For initializes and closes the DMM to avoid the hot switch.

    Other components of the program are configuration setting controls, etc. (in front of the While loop), a "current measurement" indicator and a writing-text inside the loop file operation For, several indicators of the iteration (inside the While loop, but outside the loop For) and a bunch of operations related to the grouping and table that provide graphics of groups of time vs measures.

    I don't know there are more elegant ways to perform many functions that I do and I'm not posting the VI here because I want to concentrate on what I know, it's a big problem with my program (for now!) - I can't figure out how to get out of the While loop. I tried the combinations of Boolean control, its conditions of latch and Stop / continuous if true to nothing does not.

    I want a 'Stop' button that ends the While loop, at the next opportunity, but it is not working properly, I think, because the stop button does not play with good timing, because the program runs either the loop For or the time delay at the beginning of the While loop. 'Next opportunity' can mean 'Immediately', 'at the end of the next iteration of the loop,"or"at the end of the next delay schedule." I think that if I get one of these scenarios to work, I can get an any of them to work!

    Help, please!


  • How can I enable hyper-threading?

    I have a phenom 2 x 6 1100 T UC. PC Wizard says that hyper-threading is turned off. How can I activate it and what benefits it will give me? Any advice would be appreciated.

    As afr as I know this processor (AMD) doesn't support hyperthreading.

    It has six distinct cores if.

    Hyperthreading for Intel processors operates as if it were two processors by heart.

  • How to pause the timer thread...

    Hello

    I want to make a break the "timer" thread... or I can tell want to set mode 'waiting' and then notify when something is filled.

    _CatchTimer timer = new Timer();
    CatchAppNameTimer _catchTimerTask = new CatchAppNameTimer (_catchTimer);
    _catchTimer.schedule (_catchTimerTask, 0, 5000);

    My "TimerTask (_catchTimerTask)" whenever displays a Popup...

    This popup form has two buttons - unlock, undo.

    Basically I want that, until the user clicks on... a the unlock / cancel btn, thread prepares time on standby... when the user click on open it / cancel... only after then time button thread gets notify.

    I am currently using a Boolean variable in the run method of "timertask"... to handle the deadlock situation... it's TimerTask called in every few seconds... even when the popup screen showed...

    As follows:

    public void run()
    {
    GlobalSingleton obj = null;
    obj = GlobalSingleton.getInstance ();
            
    If (obj.getShowDialog ())
    return;
           
    unlockField();
    }

    When the first "unlockFiled()" called... I put a Boolean variable as true (using Runtime store)... whose value is extracted by the getShowDialog() method.  and in

    fieldChanged (field field, int context) {} method of two Unlock / Cancel button... I put Boolean value of var as wrong... by calling...

    GlobalSingleton obj = null;
    obj = GlobalSingleton.getInstance ();
    obj.setShowDialog (false);

    But the right approach is "timer task" should not be repeated... until the user either unlock / cancel button and the control becomes out of {} fieldChanged (field field, int context) method.

    should I use a differnet thread to manage the... wait - notify operations on the Timer object... based on a Boolean variable.  I hv already tried this approach... but impossible to get a solution...

    I will be gratefull for your suggestions...

    Kind regards.

    I wouldn't use a timer for this job, I would use a Thread running continuously.  The wire would be just "sleep" for a second, then check.

    In regards to your screen, you have two choices.

    (1) the easiest is simply put your app in the foreground.  This means that you can actually leave the currently running Thread.  Because if your application is in the foreground, it will not try to block.

    With this approach, the screen that you view will be a simple screen and you can code like that.

    When the user enters the PIN code, you can make the activity on the native application.

    (2) the other option is to use a Global context screen.  It's possible but more complicated to code and I see no benefit to this approach (1), except that he's looking for a little more "pleasant".  But I don't think that "kindness" is important to you.

    As indicated on the other thread, I don't know how to close the native application.  But who needs to be discussed on the other Thread.  Have this concentration of Thread on sort how to get your screen to superimpose the native application after checking every second.  The approach I have to do it and a lot easier than trying to use a timer task.

  • How to exit the application and jump to the top any screen battery by single click?

    Hello

    for example,.

    My application contains some screen battery and train to do a task,

    the user now wants to exit the application and go to the blackberry icon page.

    How can I do that.

    Thank you best regards &,.

    Narendra Shekhawat.

    Hello

    System.Exit (0);

    or UiApplication.getUiApplication.requestBackground ();

    Kind regards

    Jochen

  • How to get the worker thread to wait for a course of UI thread ends

    I managed so far to have a thread so far work send a signal to a class in the UI thread, view a map, capture the data in this worksheet and send a signal to slot in worker thread.

    To test that the steps in the UI could do I just put the worker thread in a loop with a sleep and a counter.

    What I don't know is how interrupt the loop when the final signal is sent. I know that the signal is received but the crack does not control until that the loop ends while I want the slot for the control reception and tell the loop at the end.

    I read the documentation in BlackBBerry and Qt on the threads, mutexes, condvars, QWaitCondition etc., but none of them quite make sense to me in this situation and I can't determine which would be the best or the only one to use here.

    Anyone could do his script to work for them?

    Does not appear that the use of mutexes, condvars, are applicable to this situation, as I have only main and a worker thread to synchronize. Signal wire loop blocks so slot does not control until the loop ends. This makes sense because a thread can have only a single process point of execution. Maybe with another thread, it might work but cannot solve the logic.

    However, to find a simple solution using a thread with a loop containing beds and overall, set variables to date by the UI thread that the loop check and then fall back to sleep or ends. I don't allow so many people then, if the loop has not yet finished I invited user "More time to enter the data do you need?" and set end or loop.

Maybe you are looking for