An object-oriented programming language developed by Microsoft that can be used in .NET.
You can use a Background Thread : BackgroundWorker Component Overview
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
HI
I am working on a program where it reads a text file using zira.speak. it works fine but when i try to click on close_command button to stop it but the User Interface become non-responsive and i am unable to close it untill it has finished reading the whole text form the text file.
below is my code
Function Read_Book()
Show_Statics("< \ A I . . .Read Book >")
Dim pic_counter As Integer = 0, FAF As Integer = 0, File_Create_Object, filename, objStartFolder, objFSO, objFolder, colFiles, Script_Disctionary, Opened_File, File_Row
Dim File_Line, Books(0)
objStartFolder = "D:\All Projects\Demo Projects\AI-Projects\Books"
objFSO = CreateObject("Scripting.FileSystemObject")
objFolder = objFSO.GetFolder(objStartFolder)
colFiles = objFolder.Files
For Each objFile In colFiles
Books(FAF) = objFile.Name
FAF = FAF + 1
ReDim Preserve Books(FAF)
Next
For i = 0 To FAF - 1
If i = 0 Then
Zira.speak(" Allright , hope you are sitting tight. I am going to read" & Books(i) & "to you")
Else
Zira.speak(" Do you want to take a break or I must start reading the" & i & "Book for you.")
End If
Try
File_Create_Object = CreateObject("Scripting.FilesystemObject")
Script_Disctionary = CreateObject("Scripting.Dictionary")
Opened_File = File_Create_Object.OpenTextFile(objStartFolder & "\" & Books(i), 1)
File_Row = 0
Do Until Opened_File.AtEndOfStream
File_Line = Opened_File.Readline
stat_counter_all += 1
Script_Disctionary.Add(File_Row, File_Line)
File_Row = File_Row + 1
Zira.speak(File_Line)
LIve_Status.Width = 36
Loop
Catch ex As Exception
Show_Statics("< \ A I . . .Error >")
Zira.speak("There is an error." & "the," & ex.Message)
End Try
Next
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
how to fix it >
An object-oriented programming language developed by Microsoft that can be used in .NET.
Answer accepted by question author
You can use a Background Thread : BackgroundWorker Component Overview
Hello,
You can use asynchronous coding via Task coupled with await keyword and have an option to cancel and also show progress if needed. I have several basic code samples.
Note this extension guards against cross threading issues.
And yes i also have a question on that camera preview window i wanted to add some more property like height and width to that Bitmap inside we are drawing " This is a test " string so that it shows less background of black box - I kinda of new to this thread designs of microsoft community it confuses me where to ask or write >