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

Similar Messages

  • Using a dll function that does not have any inputs from a VI

    Hello all, I'm very new to Labview, I have wraped a dll library using the LVlib wizard and now I am trying to use it in a project.  I have a function that does not take any inputs or return any thing except that a struct is populated with some status information as part of the call.  I am able to draw a StartInterface VI because my void startInterface(const char* configFile, struct status_struct* status) takes the location of a configutation file as an input. But I can not figure out how to connect my Call Library Node to my a function vi that does not have any inputs ( void shutdownInterface(struct status_struct* status)). 
    Note that the status struct is deffined to be only and out put at the creation of the LVLIB.
    Thanks, Mike

    Thanks for the responses guys:
       I think I am aware of the conotations of inputs and outputs when I created the lvlib I specified the argument  struct status_struct* status as only an output instead of the default of input and output.
    I do not think that I am doing anything as complex as function callbacks. My immediate goal is to have an executable (I have application builder) with two buttons and two three text fields one text field for the input of the config file, two text-fields for a cstring that is contained in the status struct; one button to start the interface and one button to stop the interface. 
    This is in all likely hood a case of my self being too dense and missing something fundimental ;-)  I just can't figure out how to wire the shut down method after I've configured the call library node. See the attached pictures:
    Attachments:
    Start.jpg ‏7 KB
    shurtdown.png ‏9 KB

  • The timekeeping system we use does not like HTML 5 so what is the latest version of Firefox that does not use HTML 5?

    We have been told by our timekeeping system provider that the latest versions of FireFox, Chrome and IE are not compatible with their websites at this time. I was told that it was because of the use of HTML 5 by the more recent versions of these web browsers. I need to download the most recent version of FireFox that does not use HTML 5. Can anyone tell me which version this would be?

    It isn't "Timesheet Next Generation", is it? We had a thread on that here: [https://support.mozilla.org/questions/961306 Websites using php and mysql stopped sorting drop down lists properly starting last week. Did something change?]
    Unfortunately, HTML5 is a large specification with a lot of parts that has been implemented in pieces over the course of several years. It would be really helpful if your vendor could indicate what EXACTLY is not compatible and then it could be researched. Otherwise, you'd have to use trial and error. Either way, you would end up with an older browser that isn't safe to run on the internet. It could be time to consider other vendors...

  • Creating a page that does not exist

    Hi everyone,
    Is it possible to create a page that does not exist based on the user input?
    By does not exist I mean that it is not stored in your computer and JSP will generate the page based on the user input. For example, in forums the user can create a new topic and based on the options selected a page will be created and stored that was not present before. The same thing happens when a message has a large number of replies, in which a new page will be created and attached to the previous page. I hope that I am not misunderstanding the concept of creating pages in forums.
    Any help is greatly appreciated.
    Regards,
    Basil Mahdi

    Hi,
    what happens in the forums is that you type in a message and that message is stored in a database. Along with your message the number of thread, forum number and message number is stored. Next time somebody wants to read your message, this message is taken from the db and shown to you by the jsp. The JSP ofcourse does more thant taht it shows also other messages and static HTML.
    http://galileo.spaceports.com/~ibidris/

  • Login that does not use https

    I don't have access to https sites from my current work facility.
    Do you have a login method that does not use HTTPS?
    Is there any way that I can link my metalink account and my OTN account, and get to OTN through my metalink account?
    David

    Okay ... I fixed this, Oracle XE finally convinced them to let us have access to https at OTN.
    David

  • When are you going to create a captcha that does not reguire bc

    When are you going to create a captcha that does not reguire bc

    CAPTCHA for non-BC forms and other forms improvements will be high on the list for consideration for the release following 8.0 .
    You can post in "Ideas for Features" - need to have CAPTCHA abilities for non-BC sites .
    Here is the link:
    http://forums.adobe.com/message/6114695#6114695
    Thanks,
    Surjeet

  • How can I create a template that does not have automatic formatting but my own?

    I have just switch to a Mac from a PC and am having a terrible time with pages.  All I want to do is create my own template that has NO AUTOMATIC FORMATTING so I can do my own.
    There is nothing in the HELP sections on how to delete the automatic formatting.  I do not want to use any of their Outline Templates just make up my own.
    I would be so so grateful if someone could help me with this.  I took a one-on-one and his idea of how to get rid of formatting in my own template DID NOT WORK!
    Thanks, Deborah

    Deborah
    Hard to see your problem, and if there is something THAT DOES NOT WORK! it would obviously be useful to know WHAT that is and WHY you believe it does not work, so we can ACTUALLY RECOMMEND A SOLUTION.
    Just select any text and change it to whatever you want using the toolbar and/or the Text inspector.
    The Outlines are just a view of your text, in a form that lets you easily organise and move it around.
    Menu > View > Show Styles Drawer
    Reveals whatever style has been applied to a heading or text and you can update or create new styles by clicking on the small triangle next to it > Redefine style from selection
    When you are finished just save it as a Template.
    Peter

  • Keithley 6487 Driver That Does Not Use IVI

    Hi,
    Does anyone know if a driver set has been developed for the Keithley 6487 that does not require the Keithley IVI? To date I have been using .llb packages to control instruments and would prefere to use one in this case if possible.
    Many Thanks
    Ben

    Hi Ben,
    Thank you for contacting National Instruments. Please only post once as posting the same question many times divides the effort of the group and generally results in a longer resolution time.
    Duplicate post
    Thanks
    Andrew McLennan
    Applications Engineer
    National Instruments

  • Building an application that does not use any local program files or libraries

    I need to build an application that will not use any local libraries or LabView program files(even if LabView is installed on the PC). I also am curious if anyone knows if there is a way to debug such an application(in it's compiled state).
    Any help on these topics would be greatly appreciated.
    -Nate
    Solved!
    Go to Solution.

    Hello,
    I am unclear on what you are trying to accomplish here. As the previous poster mentioned, if you enable debugging when building your application, you can remotely connect and probe the block diagram of the running executable. Executables use the run-time engine but could also access drivers or other run-times if using a specialized toolkit/module. This all depends on your application.
    -Zach
    Certified LabVIEW Developer

  • Creating a Report that Does Not Require a Target

    I have several reports I'm building that work across all systems of a particular type. For example, I want to create a table of all of the systems with all of their software versions, another table with all of the systems and all of their free capacities and raid profile types (to best select a system to allocate capacity on) ...
    As such, I would like to build a report where I do NOT have to choose a specific target. Is this possible?
    My report definitions allow me to choose a type, but I can't find a way to say "but don't require a target", here is the report metadata for reference...
    l_target_type := MGMT_IP_TARGET_TYPES();
    l_target_type.extend(1);
    l_target_type(1) := 'my_storage_type';
    l_report_title_nlsid := 'Federated Capacity and Configuration Report';
    l_report_owner := mgmt_user.get_repository_owner;
    -- create a report definition for the report
    l_report_guid := mgmt_ip.create_report_definition (
    p_title_nlsid => l_report_title_nlsid,
    p_description_nlsid => 'Display of Configuration Information',
    p_owner => l_report_owner,
    p_category_nlsid => 'Storage',
    p_sub_category_nlsid => 'Storage Category',
    p_late_binding_target_types => l_target_type,
    p_show_table_of_contents => 1,
    p_system_report => 1,
    p_component_name => l_target_type(1)
    );

    It is a bit more complex, but I will boil this down:
    - Yes, I'm using the term System loosely, I am doing a query across a bunch of appliances in one case, there is no target identifier associated with it and, as such, the SQL does NOT include a where clause like i.TARGET_GUID = ??EMIP_BIND_TARGET_GUID?? so I would prefer the user does not have to select this
    - In another case I am in a detail report and do not want the user to have to choose the target (you can refer to another post on this), but basically, I get a table back using the BIND_TARGET, the user can click a column to get details on the adapter (for example), they click on it and are confronted with a target selection. I would rather "carry over" the target selection from the master report or I suppose I could "hide" the target GUID in the master report and then pass it as a parameter (my detail reports, in this case, are not home page reports and can only be accessed through the master report)
    Either way, I don't want to be confronted by the target selection.

  • How to install a package that does not use DESTDIR?

    Hi All
    I am trying to create a PKGBUILD for a package called cantera.  This package uses the standard "configure", "make", and "make install" process; however,  "--prefix" is supported but DESTDIR is not used.  Unfortunately, this package is very large (many files) and "make install" install with absolute path names.  Is there any strategies for handling this situation?  An example of another package that handles this would be great.
    Thanks
    Kevin

    It doesn't work for me, I get the following error:
    /bin/install -c ijs_server_epsonepl -c /var/abs/local/epsoneplijs/pkg/usr/bin/ijs_server_epsonepl
    /bin/install: cannot create regular file `/var/abs/local/epsoneplijs/pkg/usr/bin/ijs_server_epsonepl': No such file or directory
    make: *** [install] Error 1
    ==> ERROR: Build Failed.  Aborting...
    So I have to create a folder called usr/bin in my pkg-folder, then it will work.
    But this is stupid, can't makepkg create those folders by itself?
    Hmm ok tried creating the folders and still the same error, here is my PKGBUILD:
    pkgname=epsoneplijs
    pkgver=0.4.0
    pkgrel=1
    pkgdesc="a Epson EPL printer driver for ghostscript"
    url="http://sourceforge.net/projects/epsonepl/"
    source=($pkgname-$pkgver.tgz)
    md5sums=('8bc16b9df5b2a4168abc773745b9b2d7')
    build() {
    cd $startdir/src/$pkgname-$pkgver
    ./configure --prefix=/usr
    make || return 1
    make prefix=$startdir/pkg/usr install
    Whats wrong, I don't get it... 

  • HT2518 how do you transfer video from a DVD based camcorder that does not use USB?

    How do you transfet older video on tape and DVD based camcoder that do not have usb?
    looking at buying a MacBook 15.4

    I have done this for someone else with Tape Deck coax out through USB if you have installed a TV USB application such as Hauppauge WinTV HVR; recording with TV App which is rather tedious.
    Check out these - you may find better ways to do it depending on camcorder.
    http://www.ehow.com/how_2005441_camcorder-pc-usb.html
    http://www.bing.com/videos/search?q=camcorder+media+to+pc&FORM=BVFD#

  • Recover a volume using Time Machine that does not exist anymore

    My virtualized SL server has been mounting a data volume residing on a Buffalo Terastation via iSCSI. For reasons unknown to me I cannot mount this volume any more. However, I have a current backup of this volume in Time Machine.
    My intent is now to create the volume new and empty and to restore Time Machine's respective contents onto this empty volume. How should I go about this?
    Thank you for any feedback.
    Stefan

    If this is an iCloud ID, and if the old ID is yours and your current iCloud ID was created by editing the details of this old ID (rather than being an entirely new ID), go to https://appleid.apple.com, click Manage my Apple ID and sign in with your current iCloud ID.  Click edit next to the primary email account, change it back to your old email address and save the change.  Then edit the name of the account to change it back to your old email address.  You can now use your current password to turn off Find My iDevice, even though it prompts you for the password for your old account ID. Then save any photo stream photos that you wish to keep to your camera roll.  When finished go to Settings>iCloud, tap Delete Account and choose Delete from My iDevice when prompted (your iCloud data will still be in iCloud).  Next, go back to https://appleid.apple.com and change your primary email address and iCloud ID name back to the way it was.  Now you can go to Settings>iCloud and sign in with your current iCloud ID and password.

  • Many times when I click on a link that does not use a new tab, a new page opens under my current page, instead of 'on top'. How do I get new pgs to Open On Top

    No further information.

    Waka, I have Kaspersky running 24/7 but Cor-el (from Superman, I think) gave me a list of software to try.
    Cor-el, the middle click seemed to work on a page that went under, which I deleted and tried again with the wheel click.
    Waka and Cor-el, I have been planning to reinstall my Windows 7 OS and upgrade it to Pro, from Home at the same time. Will possibly re-partition C: and -will- reformat it. Will have to re-install ALL my software plus some of my softwares' user information, which I have also backed up, along with favorites and many others.

  • Create a hyperlink that does not open a new window if a window containing the url is already open?

    Is there a way to create a hyperlink to a url that "jumps to" the URL's window if it is already open in the browser?  Therefore a new window is not opened and the existing window containing the hyperlink would not change either.
    If the target url is not already open, then yes the link could either open in a new window or in its existing window.
    Does anyone know if there is a command/code for this? 

    Ok, so to be clear, I should add all of the following:
    Header 1
    function getCookie(c_name) {
    if (document.cookie.length>0)   {
    c_start=document.cookie.indexOf(c_name + "=");
    if (c_start!=-1)     {
        c_start=c_start + c_name.length+1;
        c_end=document.cookie.indexOf(";",c_start);
        if (c_end==-1) c_end=document.cookie.length;
        return unescape(document.cookie.substring(c_start,c_end));
    return "";
    function wOpen () {
    var cookiename = getCookie ('winFlag');
    newWin = window.open("YOURPAGE.html","myWin'","height=200, width=200");
    newWin.blur();
        document.cookie = "winFlag=1";
    into 1 file?  And that is the file that links to the music page?
    I don't know if my Flash music page creates a cookie onto the user's browser.  That would be necessary for this to work, right?

Maybe you are looking for