I am developing an app for windows phone. My question is how can I trigger an event after 2 seconds?
Private Sub btn1_Click(sender As Object, e As RoutedEventArgs) Handles btn1.Click
Dim input As String = txtinput.Text
Dim last As Char = input(input.Length - 1)
If last = "A" Then
Dim final As String = input.Substring(0, input.Length - 1) & "B"c
txtinput.Text = final.
'start timer here
'trigger an event after 2 seconds
ElseIf last = "B" Then
Dim final As String = input.Substring(0, input.Length - 1) & "C"c
Dim tmr As TimeSpan = TimeSpan.FromSeconds(2)
txtinput.Text = final
'start timer here
'trigger an event after 2 seconds
Else
txtinput.Text = input + "A"
End If
End Sub
I am using Visual Basic as my language in developing this. Any help would be much appreciated.
declare dispatcherTimer inside the class
then create instance of dispatcherTimer whereever you want, set time span
and here is your handler
*converted code to VB from here, though I have not tested it..it may work for you..