Using time() function in multithreaded application

I am using time() function in a multithreaded application with NULL argument for getting current time.
Some time it's observed that we get a time one minute earlier than current time (3600 seconds).
Is there a problem in the usage of the function?
I am using expression : currenttime = time(NULL);
I had seen some people using following way - time(&currenttime );
Will above two behaves differently in multithreaded environment?
[I  am using  Sun C++ 5.5 compiler on Solaris 8]

How do you compare actual time against the time seen by your threads? If your threads are printing the value from time(2) to stdout, it's possible that you're seeing an artifact of thread scheduling and/or output buffering.
I really doubt that you have a concurrency problem, but anyway make sure that you include the -mt option on your compile line:
CC -mt blahblahblah...

Similar Messages

  • Does the Timer() function support multithread?

    Hello,
    In my application, there would be more than 1000 conversations to be monitored. I am going to design a woker thread for each conversation to determine the timeout of the communication, so I must using the timer mechanism. Due to just can create (max )16 async timers, so I want to use Timer() in the worker thread. I'd like to know if the function support multithread and if it will not be disturbed in a thread?
    David

    Hi David,
    The 'timer' used by the Timer() function is global and not thread specific. Note that Timer() returns the number of seconds elapsed since the FIRST call to the Timer() function. This is independent of the thread where the FIRST and current calls take place. So, the values returned are kind of a global 'time' since the first Timer() call in your program. I would recommend that you FIRST call Timer() in your main thread before running your other threads and then the other values returned in any thread are the 'seconds' since this call.

  • How to add Timer functionality to Agentry application?

    I want to add timer functionality in my Agentry app.
    After selecting particular button, the timer should start and end after other button selected.
    I am using Eclipse editor for coding and I cant see any option for timer functionality.

    Prit,
    The actiontimer program is a windows program that was developed to execute the action at certain intervals.  This program is a windows program that naturally will not run on Android and there is no equivalent android program that exists at this time.
    Also, since Android is a more locked down OS, we don't have the same capabilites in terms of other external applications invoking actions within the Agentry client that we do with Windows.
    The Agentry 6.0.x client just doesn't have the same capabilities needed to implement this functionality.  However as I mentioned, with theSMP 3.0 (Agentry 7) client we have introduced the OpenUI SDK which should give you the ability to write an equivalent capability on the Android platform.
    The OpenUI API documentation can be found at the following link
    Agentry OpenUI API
    --Bill

  • How do I use Time Machine to restore applications to a new computer?

    Hello again
    I just upgraded to a newer computer (not brand new, though: 20" imac with intel core 2 duo).
    I traded in the older one and the files from it were transferred over, but not the applications.
    Now, a year ago I took my tech friend's advice and used TM to back up the whole hard-drive .... so last night i used TM and navigated through Finder to see that all the applications are there in the Application folder. Tech friend said that i could just restore the Application Folder .... but this isn't an actual install .... so what other folders will i need to restore?
    Or should I just restore the whole hard drive? .. if i do this, will it copy over Snow Leopard too? cause the imac only came with leopard and i just had to install snow and then it took all night to get the upgrades and install them !
    Thanks for any advice and help.
    Elizabeth

    I would recommend you just reinstall the applications from their original distribution discs. Some applications require files that are not installed in the Applications folder alone. You would need to know what specific ones to look for. Reinstalling a whole system or major folder from an old TM backup will surely render a malfunctioning system unless the system you would be restoring is known to work on that computer. For more on using Time Machine see:
    A  whole  lot  about  Time  Machine for help with TM problems.  Also you can select Mac Help from the Finder's Help menu and search for "time machine" to locate articles on how to use TM.  See also Mac 101- Time Machine.

  • How to write a use time function in elsif

    Hai All
    I have generated an attendance form and my problem is while i am using elsif insert operation there and there is no updation.
    My need is
    this is my table structure
    EMPCODE NUMBER
    EMPNAME VARCHAR2(25)
    BARCODE VARCHAR2(25)
    INTIME VARCHAR2(25)
    OUTTIME VARCHAR2(25)
    INTRTIMEIN VARCHAR2(25)
    INTROUTTIME VARCHAR2(25)
    ATTEND_DATE
    when timing between 0145 and 0630 then update in outtime
    and 0630 to 1000 then insert in intime column
    and 1100 to 1300 then insert in intime column or
    update in outtime column and
    then 1600 to 1730 then to insert into intime column or else
    when intime is not null then update in outtime column
    I have tried and only insert id doing opver there Pls tell what wrong i have made
    declare
    t_in varchar2(25) := :bartime;
         t_out varchar2(25) := :bartime;
    -- t_date dail_att.attend_date%type;
    Begin
    go_block('TEST_SRI');
    FIRST_RECORD;
    LOOP
    if :bartime between 0145 and 0615 and t_out is null and t_in is not null then
    update dail_att set outtime = :bartime where barcode= :barcode
    and ATTEND_DATE = :BARDATE-1 ;
    elsif :bartime between 0630 and 1000 and t_in is null then
    insert into dail_att(barcode,intime,attend_date)
    values(:barcode,:bartime,:bardate);
    elsif :bartime between 0630 and 1000 and t_in is null then
    update dail_att set outtime = :bartime where barcode= :barcode
    and ATTEND_DATE = :BARDATE-1 ;
    elsif:bartime between 1130 and 1330 and t_in is null then
    insert into dail_att(barcode,intime,attend_date)
    values(:barcode,:bartime,:bardate);
    elsif :bartime between 1130 and 1330 and t_in is not null then
    insert into dail_att(barcode,intrtimein,attend_date)
    values(:barcode,:bartime,:bardate);
    elsif :bartime between 1615 and 1815 and t_in is null then
    insert into dail_att(barcode,intime,attend_date)
    values(:barcode,:bartime,:bardate);
    elsif :bartime between 1645 and 2000 and t_in is not null and t_out is null then
    update dail_att set outtime = :bartime
    where barcode= :barcode and outtime is null and ATTEND_DATE = :BARDATE-1;
    elsif :bartime between 2000 and 2200 and t_in is not null and t_out is null then
    update dail_att set outtime = :bartime
    where barcode= :barcode and outtime is null and ATTEND_DATE = :BARDATE;
    EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE' OR :BARCODE IS NULL;
    end if;
    NEXT_RECORD;
    --message('hai');
    END LOOP;
    delete from dail_att cascade;
    forms_ddl('commit');
    forms_ddl('truncate');
    exception
    when others then
    forms_ddl('rollback');
    message(sqlerrm||dbms_error_Text);
    message(sqlerrm||dbms_error_Text);
    End;      
    Regards
    Srikkanth.M

    I got it by converting by date time function
    Edited by: Srikkanth.M on Apr 10, 2010 2:19 PM

  • How to use Time Function

    I have two times say
    2310, 0050 - How can I find out using java that the difference between these two is 100 minutes or 1 hour 40 minutes.
    What libraries are used to find this out ??

    I need a time function which will do it.....I will be
    surprised if Java don't have something inbuilt....Try splitting the time into two strings for the hours and minutes, using the functions DrLaszloJamf provided for you.
    minutesSinceMidnight = hours * 60 + minutes; Otherwise, the GregorianCalendar is pretty cool.

  • How can i measure the transmision time in gpib with visual basic with more precision if i use time() function?

    I want to take a measurement of the time that i use to make a gpib transmision in a Visual Basic program,i use the function TIME() to take the time in the begining and other time in the end,but this way only give me precision of seconds, and i want miliseconds,can i use other function,other way?
    Can answer in spanish?

    Try using GetTickCount() API function, which provides millisecond precision. If you need more precise timer, try using QueryPerformanceCounter() function.
    Makoto

  • Using Timer functions in parallel with VISA functions

    I have an application using two VISA sessions operating
    in parallel controlling a LeCroy oscilloscope and a Pacific
    Power Source through GPIB.
    In a sub-VI, I setup the scope and put it in single acquistion
    mode. Then, in the top level VI, I am reading a global variable
    that detects when the scope is armed - when this flag is set, I am
    using the second VISA session to control the power to the circuit
    under test.
    I have a while loop with a small delay (100ms) to poll the
    global variable, (I also use the global value to exit the loop.)
    This technique does work, although there is a 10 second delay
    between the time the scope is armed for acquisition and the time
    the command is recieved to turn on th
    e power source.
    If I take the Wait(mS) function out of the while loop, the command is
    sent immediately following when the scope is armed, with no delay,
    and even though I don't seem to be missing the trigger, I would prefer
    just a small delay, to ensure that the scope is ready every time. Also,
    from what I've read, it's not good practice to run loops without even
    some small delay.
    Is there a better approach to this? I hope I have expained the
    problem sufficiently - any help or insight would be appreciated.
    thanks,
    Mike Selecky

    I understand the structure you're talking about, but I don't understand why they have to be in seperate loops. The flag from the scope (actually the error cluster output from the scope command function) is the data that establishes the sequentiality between the two steps. If errors are handled properly in the scope and power supply subVIs all you have to do is string the teo routines together using the error clusters and you're done.
    What you want in the subVIs is to create them such that the first time they run they initialize the VISA session and store the reference to it in an uninitialized shift register. Every time after that (or until an error is detected after the command operation) the part of the code that reads or writes the instrum
    ent uses the cached reference. To allow the code to stop cleanly, you might also want to include a front panel control that tells the subVI that the system is shutting down and to close the VISA session when it's done with it.
    Errors propegated into a subVI containing VISA calls will essentially bypass those calls as long as all the error clusters are connected together. What actually happens is that the low-level functions abort as soon as they see the error input and simply pass the error in to their error output.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • What is the best way to reboot the system using system function in an application?

    Dear Developers,
    Greetings!!!!
    As, i would like to reboot my WinCE 7 based system with an application. I am using one system defined function SetSystemPowerState.
    Below is the sample code -
    DWORD result;
    result = SetSystemPowerState(NULL, POWER_STATE_BOOT,0);
    if(result){
    DEBUGMSG(TRUE,(TEXT("The system is going to boot\r\n")));
    else{
    DEBUGMSG(TRUE,(TEXT("ERROR: While trying to reboot the system :%d\r\n"),GetLastError()));
    But, when I run my application I got the following debug messages -
    100418 PID:4740016 TID:319004e CePerf.dll is absent - performance data will not be recorded
    100422 PID:2cc0652 TID:234063a OSAXST1: >>> Loading Module 'coredll.dll' (0x9E411740) at address 0x40010000-0x40165000 in Process 'System_Reboot_DEBUG.exe' (0x9E4C379C)
    100423 PID:2cc0652 TID:234063a OSAXST1: >>> Loading Module 'System_Reboot_DEBUG.exe' (0x9E4C379C) at address 0x00010000-0x00016000 in Process 'System_Reboot_DEBUG.exe' (0x9E4C379C)
    PB Debugger Loaded 'System_Reboot_DEBUG.exe', no matching symbolic information found.
    100435 PID:2cc0652 TID:234063a OSAXST1: >>> Loading Module 'locale.dll' (0x9E412C00) at address 0x40170000-0x401B1000 in Process 'System_Reboot_DEBUG.exe' (0x9E4C379C)
    100526 PID:2cc0652 TID:234063a OSAXST1: >>> Loading Module 'normalize.dll' (0x9E412E3C) at address 0x401E0000-0x401FF000 in Process 'System_Reboot_DEBUG.exe' (0x9E4C379C)
    100535 PID:2cc0652 TID:234063a CePerf.dll is absent - performance data will not be recorded
    100537 PID:400002 TID:db0006 PM: DEBUGCHK failed in file d:\bt\2034\public\common\oak\drivers\pm\pdd\default\pwsdef.cpp at line 424
    100538 PID:400002 TID:db0006 DefaultPowerStateManager::PlatformMapPowerStateHint: returning 2
    100539 PID:2cc0652 TID:234063a The system is going to boot
    100539 PID:2cc0652 TID:234063a Dll list:
    100543 PID:2cc0652 TID:234063a OSAXST1: <<< Unloading Module 'coredll.dll' (0x9E411740) at address 0x40010000-0x40165000 in Process 'System_Reboot_DEBUG.exe' (0x9E4C379C)
    100543 PID:2cc0652 TID:234063a OSAXST1: <<< Unloading Module 'normalize.dll' (0x9E412E3C) at address 0x401E0000-0x401FF000 in Process 'System_Reboot_DEBUG.exe' (0x9E4C379C)
    100544 PID:2cc0652 TID:234063a OSAXST1: <<< Unloading Module 'locale.dll' (0x9E412C00) at address 0x40170000-0x401B1000 in Process 'System_Reboot_DEBUG.exe' (0x9E4C379C)
    100545 PID:2cc0652 TID:234063a OSAXST1: <<< Unloading Module 'System_Reboot_DEBUG.exe' (0x9E4C379C) at address 0x00010000-0x00016000 in Process 'System_Reboot_DEBUG.exe' (0x9E4C379C)
    PB Debugger Unloaded symbols for 'System_Reboot_DEBUG.exe'
    But, the system does not boot. Any conclusion with the above observations???

    Using SetSystemPowerState (NULL, POWER_STATE_RESET, POWER_FORCE) will finally call the  KernelLibIoControl((HANDLE)KMOD_OAL, IOCTL_HAL_REBOOT, NULL, 0, NULL, 0, NULL)
    you have to implement IOCTL_HAL_REBOOT Kernel IOCTL in OAL part of your BSP.
    Please mark as answer, if it is correct.
    Please vote,if it is helpful post.
    Vinoth.R
    http://vinoth-vinothblog.blogspot.com
    http://www.e-consystems.com/windowsce.asp

  • Does anyone know how to add time using TIME function?

    Hi,
    I just switched from Excel (lol) and found an error in a key calculation i use. Does anyone know how to automatically add hours to a time? i.e. i have to convert Pacific Time to other U.S. Time Zones so in the past I used this formula in Excel (=B6+TIME(3,0,0)) which is now not working in Numbers. Is there an equivalent?
    Thanks for your help!
    Alexandra

    Hello
    The Terms of Use ruling this forum states:
    -+-+-+-+-+-+-+-
    +to help you resolve issues, ask questions, get tips and advice, and more.+
    +If you have a technical question about an Apple product, be sure to check out Apple's support resources first by consulting the application Help menu on your computer and visiting our Support site to view articles and more on our product support pages.+
    +How do I post a question? ‚+
    +_If you searched the forums and didn't find an answer to your question or issue_, click the Post New Topic link at the top of a relevant forum page to post your own question.+
    -+-+-+-+-+-+-+-
    Your question was aked and responded many times.
    Searching in existing threads would have give you the response.
    When I try to help users in English, I often look in a dictionary but it seems that for many users, reading the Help or the PDF User's Guideis too much work.
    In cell D3, the formula is simply:
    =TIME(HOUR(B)HOUR(C),MINUTE(B)+MINUTE(C),SECOND(B)SECOND(C))
    which match the Numbers's syntax which, what a surprise, is not XL's one
    Yvan KOENIG (from FRANCE mercredi 28 mai 2008 17:39:56)

  • Error using time function AGO()

    Hi everyone
    I am trying to make this report using OBIEE 11.1.5 with Essabas as datasource:
    Account     ActualMonth     MonthPreviousYear     PreviousMonth     Actual Year
    I have the time dimension (like in HFM), divided into two dimensions Years (Total -> Years) and Period (Total -> Quarters -> Months).
    I use the AGO() function in the repository (BML) to get PreviousYear and PreviousMonth:
    PreviousYear: AGO("Essbase_1"."Data"."Measure" , " Essbase_1"."Year"."Gen2,Year" ,1)
    PreviousMonth : AGO("Essbase_1"."Data"."Measure" , " Essbase_1"."Period"."Gen4,Period" , 1)
    If I use the columns PreviousMonth or PreviousYear separately they work fine. However using both in the same query, I get an error:
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: [nQSError: 22036] Level in Ago function (Gen2,Year) must be a rollup of (or equivalent to) the measure level (Gen4,Period). (HY000)
    Any idea how to solve this issue?
    Many Thanks in advance
    Mojito

    Look at the following links:
    http://obiee101.blogspot.com/2008/11/obiee-ago-and-todate-series.html
    http://oraclebiee11g.blogspot.com/2011/01/ago-function-in-obiee-11g-answers.html
    hope this helps.

  • Using transactions in a multithreaded application

    Is it possible to share a single OracleConnection object amongst multiple worker threads (avoiding all the problems of a connection pool), but still be able to begin/commit/and rollback transactions enlisted per thread?
    Here is a sample of my wish list code:
    On Thread One we want to be able to to this:
         Dim tx as new OracleTransaction = m_OraConnection.BeginTransaction()
              [Do Oracle stuff here]
         tx.Commit
         [This thread’s tx.commit will only commit this one transaction
    On Thread Two we want to be able to do this:
         Dim tx as new OracleTransaction = m_OraConnection.BeginTransaction()
              [Do Oracle stuff here]
         tx.Rollback
         [This thread’s tx.rollback will only rollback this one transaction
    Both of these threads use the same m_OraConnection object and this is what is unclear.  Will it work as shown in the sample?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Did not follow a specific pattern as this application is an upgrade and not a complete rewrite. If there is a specific pattern that shows this usage can you recommend it?
    The threading part is straight forward enough, but I was wondering if it was possible to share the one connection amongs the 5 - 8 threads and thus avoid the issue that seem prevalent using the connection pooling.
    This is where the question arises as if all threads are using the same conneciton object, will thier individual commits and rollbacks affect the other threads?

  • Cannot use QuickTime functions in a plain C++ application

    Hi,
    Im new to QuickTime.Now i need to use quicktime7.1 SDK functionalities in my plain C++ application.Hence I started with a plain C++ application just to check whether i can access the quick time functions there.Im currently using Dev-cpp IDE for developing my application.
    Given the sample code.
    #include<iostream>
    #include<conio.h>
    #include<QuickTime.h>
    using namespace std;
    main()
    int ver=0;
    ver=quicktime_major(void);
    cout<<"VERSION"<<ver;
    getch();
    The given program uses the quicktime function quicktime__major to get the version information.The function returns an integer value,which is the version of the quicktime installed.The function is declared with in the header quicktime.h.Hence i added the header file.
    On Compiling,I am getting some errors in the main function as listed :-
    main.cpp: In function `int main()':
    main.cpp:9: error: expected primary-expression before "void"
    main.cpp:9: error: `quicktime_major' undeclared (first use this function)
    main.cpp:9: error: (Each undeclared identifier is reported only once for each function it appears in.)make.exe: * [main.o]
    Error 1Execution terminated
    I am getting so many other errors in the quicktime header files which i am not able to get resolved.Some sample errors are listed below.
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:145: error: conflicting declaration 'kATSULineWidthTag'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:145: error: 'kATSULineWidthTag' has a previous declaration as
    `<anonymous enum> kATSULineWidthTag'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:145: error: declaration of `kATSULineWidthTag'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:145: error: conflicts with previous declaration `<anonymous enum>
    kATSULineWidthTag'
    [this same error is repeating for all the enum members in the header file ATSUnicode.h ]
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h: In function `OSStatus (* NewATSQuadraticLineUPP(OSStatus (*)(const
    Float32Point*, const Float32Point*, void*)))(const Float32Point*, const Float32Point*, void*)':
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2523: error: redefinition of `OSStatus (*
    NewATSQuadraticLineUPP(OSStatus (*)(const Float32Point*, const Float32Point*, void*)))(const Float32Point*, const
    Float32Point*, void*)'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2523: error: `OSStatus (* NewATSQuadraticLineUPP(OSStatus (*)(const
    Float32Point*, const Float32Point*, void*)))(const Float32Point*, const Float32Point*, void*)' previously defined here
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h: In function `OSStatus (* NewATSQuadraticCurveUPP(OSStatus (*)(const
    Float32Point*, const Float32Point*, const Float32Point*, void*)))(const Float32Point*, const Float32Point*, const
    Float32Point*, void*)':
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2542: error: redefinition of `OSStatus (*
    NewATSQuadraticCurveUPP(OSStatus (*)(const Float32Point*, const Float32Point*, const Float32Point*, void*)))(const
    Float32Point*, const Float32Point*, const Float32Point*, void*)'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2542: error: `OSStatus (* NewATSQuadraticCurveUPP(OSStatus (*)(const
    Float32Point*, const Float32Point*, const Float32Point*, void*)))(const Float32Point*, const Float32Point*, const
    Float32Point*, void*)' previously defined here
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2561: error: redefinition of `OSStatus (*
    NewATSQuadraticNewPathUPP(OSStatus ()(void*)))(void)'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2561: error: `OSStatus (* NewATSQuadraticNewPathUPP(OSStatus
    ()(void*)))(void)' previously defined here
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h: At global scope:C:/Program Files/QuickTime
    SDK/CIncludes/ATSUnicode.h:2578: error: conflicting declaration 'uppATSQuadraticClosePathProcInfo'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2578: error: 'uppATSQuadraticClosePathProcInfo' has a previous
    declaration as `<anonymous enum> uppATSQuadraticClosePathProcInfo'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2578: error: declaration of `uppATSQuadraticClosePathProcInfo'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2578: error: conflicts with previous declaration `<anonymous enum>
    uppATSQuadraticClosePathProcInfo'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h: In function `OSStatus (* NewATSQuadraticClosePathUPP(OSStatus
    ()(void*)))(void)':
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2580: error: redefinition of `OSStatus (*
    NewATSQuadraticClosePathUPP(OSStatus ()(void*)))(void)'
    Can anyone help me to resolve the above issues?
    Thanks in advance,
    Sans

    Antoine;
    There is a good KnowledgeBase at NI home page talking about that issue.
    If you go to www.ni.com and type +ni-daq +run +borland at the search engine of the page, the second result is the link to the KB I'm referring to.
    Hope this helps.
    Filipe

  • Create timer function that does not use start-sleep

    Hey all I would like to create a timer function that does not use the start-sleep command because this freezes my GUI. I've wrote the start of a function but it seems to move on before the specified time has finished.
    Here's what I have:
    $Global:timerCounter=0
    $Global:timer = new-object System.Windows.Threading.DispatcherTimer
    Function Timer{
    param(
    [parameter(Mandatory=$true)]
    [int]$time
    $timer.Interval = [TimeSpan]"0:0:$($time)"
    $timer.Add_Tick({
    $Global:timerCounter++
    if($Global:timerCounter -ge 1) {
    $Global:timer.Stop()
    $timer.Start()
    Then in my script i would like to call Timer -time #of seconds. It seems that when I call it the add_tick is registered and then started but it continues on with the rest of my script. Is there a better way of doing this without using start-sleep?
    Thanks!

    Okay the issue I'm having is that I have code after the $timer.start that I don't wan't to run till a powershell job is done. In all the examples I've seen it has to come to the end of the code then it starts the tick. So in your example it comes to the
    end of of your code and showsDialog() then starts ticking.
    So:
    add-type -AssemblyName system.windows.forms
    $form=New-Object System.Windows.Forms.Form
    $btn=New-Object System.Windows.Forms.Button
    $form.Controls.Add($btn)
    $btn.add_Click({$form.Close()})
    $btn.Dock='Fill'
    $btn.Font='Lucida Console, 20.25pt, style=Bold'
    $btn.Text=[DateTime]::Now
    $timer=New-Object System.Windows.Forms.Timer
    $timer.Interval=1000
    $timer.add_Tick({$btn.Text=[DateTime]::Now})
    $timer.Start()
    $form.ShowDialog()
    #I want to do other things here but only after the ps job has finished
    Thanks I really am trying to figure this out. 
    Here is the code I'm working with I guess I'm unclear on how to order the timer and the rest of my code:
    if($syncHash.mainCopy){
    $syncHash.mainJobDone = $false
    $syncHash.writeHost = $false
    while(-not $syncHash.mainJobDone){
    [System.Windows.Forms.Application]::DoEvents()
    if($syncHash.writeHost -eq $false){
    Write-OutputBox -Message "Copying"
    $syncHash.writeHost = $true
    $syncHash.inProgress = $syncHash.mainCopy | Where-Object {$_.State -match 'running'}
    $syncHash.currentCopyTime++
    }elseif($syncHash.currentCopyTime -ge ($syncHash.averageCopyTime * 2) -and $syncHash.collectionCopyTime.Count -ne 0){
    $syncHash.Unusable += $syncHash.currentMainCopyMachine
    $syncHash.computersNotForInstall += $syncHash.currentMainCopyMachine
    $syncHash.inProgress = $null
    $syncHash.mainCopyTimedOut = $True
    Write-OutputBox -Type WARNING: -Message "$($syncHash.currentMainCopyMachine) is taking too long. Removing Job.."
    Add-Content -Path $log_path -Value "$($syncHash.currentMainCopyMachine) taking to long to copy to"
    Stop-Job $syncHash.mainCopy
    }else{
    $syncHash.inProgress = $syncHash.mainCopy | Where-Object {$_.State -match 'running'}
    Write-OutputBox -Message "." -NoNewLine
    ############################# ############# So I need it to wait right here I have other code other than in this block ############# that needs to run $syncHash.currentCopyTime++
    if(-not $syncHash.inProgress){
    $syncHash.mainJobDone = $true

  • How to use elapsed time function with state machine in Lab VIEW

    Hello
    I've been trying to use state machine with elapsed time function in order to sequentially start and stop my code. The arrangement is to start the code for 1 minute then stop for 5 minutes. I've attached the code, the problem is when I place the elapsed time function out of the while loop it doesn't work, on the other hand when I place it inside the loop it does work but it doesn't give the true  signal to move to the next state. 
    Could you please have a look to my code and help me to solve this issue.
    Regards 
    Rajab
    Solved!
    Go to Solution.
    Attachments:
    daq assistance thermocouple(sate machine raj).vi ‏436 KB

    Rajab84 wrote:
    Thanks apok for your help
    even with pressing start it keeps running on wait case 
    could you please explain the code for me, the use of Boolean crossing, increment , and equal functions 
    Best Regards 
    Rajab 
    OK..I modded the example to stop after 2 cycles. Also recommend taking the free online LabVIEW tutorials.
    run vi. case statement goes to "initialize", shift registers are initialized to their constants. goto "wait"
    "start"= false, stay in current state. If true, transition to "1 min" case
    reset elapsed timer with True from shift register(counter starts at zero)."time has elapsed"=false, stay in current state(1 min). If true, goto "5min" case
    reset elapsed timer with True from shift register of previous case(counter starts at zero)."time has elapsed"=false, stay in current state(5 min). If true, goto "1min" case. Also, bool crossing is looking for "true-false" from "5 min" compare function to add cycle count.
    Once cycle count reaches 2, stop while loop.... 
    Attachments:
    Untitled%202[1].vi ‏42 KB

Maybe you are looking for

  • Movie: purchase vs rent?

    I just downloaded a free movie from iTunes, and it shows up as a rented movie that expires in 30 days. I used the "get movie" button, but there was also an "add movie" button. Both listed as "free". Are they both the same thing, or would "add movie"

  • Badi or enhancement for ME23N purchase order

    Dear All Expert, I would like to implement User Exits in T-Code ME23N for purchase order, the scenario is : If Purchase Order already has Good Receipt or Full GR then field for quantity and nett price will be disabled. So I would like to ask: 1. I fo

  • OS X Support of Certificate Key Length

    I'm trying to import a self signed root certificate for our enterprise into a Lion machine's key chain and I'm getting an error message: "An error occured. Unable to import "<cert name>" Error -67762" The certificate has a key length of 8192 bits, si

  • I can't open Photoshop elements  error message 150:30 How can I do?

    I can't open Photoshop elements  error message 150:30 How can I do? Mac OSX

  • External monitor "No Signal" message

    MacBookPro mid 2010 with 250GB solid state drive. W80183G9AGZ Two problems, they may be related Randomly for some time the computer restarts with the message "Your computer has restarted because of a problem" This generates a crash report which I alw