Quantcast
Channel: VBForums - WPF, WCF, WF
Viewing all articles
Browse latest Browse all 256

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

$
0
0
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

Viewing all articles
Browse latest Browse all 256

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>