Results 1 to 10 of 10

Thread: [RESOLVED] Thread, dispatcher - can't figure it out how to use it

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2015
    Posts
    11

    Resolved [RESOLVED] Thread, dispatcher - can't figure it out how to use it

    Hi all

    I'm learning how to start a new thread so my functions and GUI not freezing, but I don't understand how to use it.

    I have made a small program that says what I put into the textbox, and while it's speaking, I want to be able to slide the slide button. Right now I can only do it when the speak stops.

    Here is my code:
    Code:
    Imports System.Speech.Synthesis.SpeechSynthesizer
    Class MainWindow
        Dim sig As New Speech.Synthesis.SpeechSynthesizer()
        Dim rate As Double
        Dim StartTekst As String = "This is a test on how it sounds"
    
        Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs) Handles Window.Loaded
            txtboxSigTekst.Text = StartTekst
        End Sub
    
        Private Sub btnSigTekst_Click(sender As Object, e As RoutedEventArgs) Handles btnSigTekst.Click
            SigTekst(txtboxSigTekst.Text)
        End Sub
    
        Private Sub sliderRate_ValueChanged(sender As Object, e As RoutedPropertyChangedEventArgs(Of Double)) Handles sliderRate.ValueChanged
            rate = sliderRate.Value
            lblRate.Content = sliderRate.Value
        End Sub
    
        Private Sub SigTekst(SubSigTekst As String)
            sig.Rate = CInt(rate)
            sig.Speak(txtboxSigTekst.Text) ' SubSigTekst)
        End Sub
    End Class
    I have tried to insert a "dispatch" in the sub SigTekst (Dispatcher.BeginInvoke(New Action(AddressOf SigTekst))) but non of the different metodes I have tried, is working.
    What do I do wrong? Do I insert Dispatcher in the sub SigTekst or should it be in another place?

    Can anyone help me to understand this?

    -Salva
    Last edited by Salvadk; Sep 25th, 2015 at 08:45 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width