header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
PowerShell stops working on event
Last Post 02 Feb 2010 07:01 AM by davidlt. 0 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
davidltUser is Offline
New Member
New Member
Posts:2
Avatar

--
02 Feb 2010 07:01 AM
    Hi everyone, here is the code:
    --------------------------------------------
    Add-Type -AssemblyName System.Speech
    $talker = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer

    $talker.add_SpeakCompleted({
    Write-Host "End"
    })

    $talker.SpeakAsync("Hello!")
    --------------------------------------------

    This one should say "Hello". The problem is that that I get message that PowerShell stopped working. I tried to put a brake point in the event , but it looks that it doesn't get into it. It is possible to prevent this problem by using "Speak" method instead, but SpeakCompleted in that case is never fired, but SpeakProgress are fired. If you would change the event in the code with any other it will crash too.

    In some cases it does work as I want, let's say this:

    --------------------------------------
    $talker = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer

    $buttonSpeak.add_Click({
    $talker.add_SpeakCompleted({
    Write-Host "End"
    })
    $talker.SpeakAsync("Hello!")
    })
    ------------------------------------------

    In this case the code works perfectly, but you every time I add event handler, that's not good.

    I have another code that uses SpeakAsync and SpeakCompelted event and fully works as I want.

    Anyone could enlighten me what I am doing wrong?

    Thanks in advance,
    David
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer