Backgroundworker doesn't work... VB.Net - vb.net

this is my code:
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
For i = 0 To 1000
Dim inum As String = i & "0"
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://www.google.nl/search?q=site:" & combobox1.Text & "&hl=nl&start=" & inum)
Dim response As System.Net.HttpWebResponse = request.GetResponse
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
Dim sourcecode As String = sr.ReadToEnd
Dim search As String = combobox1.Text
Dim r As New System.Text.RegularExpressions.Regex("http://" & search & "/\w*")
Dim matches As MatchCollection = r.Matches(sourcecode)
For Each itemcode As Match In matches
Dim item As String = (itemcode.ToString.Split("""").GetValue(0))
Dim url As New Net.WebClient
Dim str As String = url.DownloadString("http://www.prcheck.nl/results.php?url=" & item)
If str.Contains(">0/10") Then
ListBox1.Items.Add("(0/10) " & item)
ElseIf str.Contains("1/10") Then
ListBox1.Items.Add("(1/10) " & item)
ElseIf str.Contains("2/10") Then
ListBox1.Items.Add("(2/10) " & item)
ElseIf str.Contains("3/10") Then
ListBox1.Items.Add("(3/10) " & item)
ElseIf str.Contains("4/10") Then
ListBox1.Items.Add("(4/10) " & item)
ElseIf str.Contains("5/10") Then
ListBox1.Items.Add("(5/10) " & item)
ElseIf str.Contains("6/10") Then
ListBox1.Items.Add("(6/10) " & item)
ElseIf str.Contains("7/10") Then
ListBox1.Items.Add("(7/10) " & item)
ElseIf str.Contains("8/10") Then
ListBox1.Items.Add("(8/10) " & item)
ElseIf str.Contains("9/10") Then
ListBox1.Items.Add("(9/10) " & item)
ElseIf str.Contains("10/10") Then
ListBox1.Items.Add("(10/10) " & item)
Else
ListBox1.Items.Add("(0/10) " & item)
End If
Label2.Text = ListBox1.Items.Count
Next
If Not sourcecode.Contains("<b>Volgende</b>") Then
MsgBox("")
Exit For
End If
Next
End Sub
and combobox1.text = www.google.nl ( example )
at button 1 the code is:
BackgroundWorker1.RunWorkerAsync()
and if backgroundworker is done:
Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
MsgBox("Done")
End Sub
if i click button 1, i get within a half second the message: Done
what's wrong with the code??
if i put the code inside backgroundworker1 just in button1 it works but goes really slow..

You can only update the UI from within the main application thread, in this case you're attempting to do it via a background thread that has been created by the background worker which will throw an exception as you've found.
What you'll need to do it run the code which adds to the ListBox on the main thread which you can do via BeginInvoke and a custom delegate which takes the item you want to add as a parameter, the delegate can then add the item to list box - there's an example of how to do this in the docs for BeginInvoke.

I would return a list or array of items to be added from the background worker and then fill the ListBox in the RunWorkerCompleted event handler.

Related

VB NET problems with background worker

While my background worker is doing his job, I want to change a label in main form telling what process is taking in that time.
The app works with some files, so I need to pass the information of the file the app is working on.
My Background Worker
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
If (Not System.IO.Directory.Exists(caminho & "\results")) Then
System.IO.Directory.CreateDirectory(caminho & "\results")
End If
For Each folder As String In System.IO.Directory.GetDirectories(caminho)
Dim split As String() = folder.Split("\")
Dim parentFolder As String = split(split.Length - 1)
If (Not System.IO.Directory.Exists(caminho & "\results" & "\" & parentFolder)) Then
System.IO.Directory.CreateDirectory(caminho & "\results" & "\" & parentFolder)
End If
For Each file As String In System.IO.Directory.GetFiles(folder)
output = file
'Dim imgFile As System.Drawing.Image = System.Drawing.Image.FromFile(file)
Dim thumbimage As Bitmap
Dim originalimage As Bitmap
Dim width As Integer = TextBox2.Text '# this is the max width of the new image
Dim height As Integer = TextBox3.Text '# this is the max height of the new image
originalimage = System.Drawing.Image.FromFile(file)
thumbimage = New Bitmap(width, height)
Dim novonome As String = Path.GetFileNameWithoutExtension(file)
Dim gr As Graphics = Graphics.FromImage(thumbimage)
gr.DrawImage(originalimage, 0, 0, width, height)
thumbimage.Save(caminho & "\results" & "\" & parentFolder & "\" & novonome & ".png", Imaging.ImageFormat.Png)
thumbimage.Dispose()
originalimage.Dispose()
Next
Next
End Sub
My On Progress Change:
Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
Label3.Text = "Working file " & output
End Sub
Isn't supposed to change the label3.text in form1 with the file it's working? Basically nothing happens to label3.
My output var is declared under Public Class Form1.
Thanks in advance.
Make sure your BackgroundWorker object has WorkerReportsProgress = True
You have to call the progress from within your loop:
For Each file As String In System.IO.Directory.GetFiles(folder)
BackgroundWorker1.ReportProgress(0, file)
...
Then in your Progress event, read the status:
Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
If e.UserState IsNot Nothing Then
Label3.Text = "Working file " & e.UserState.ToString
End If
End Sub

How to make a validation from a checkbox and radiobutton

I'm trying to make a validation where after I click in a item from the ComboBoxwithout check any of the RadioButton it will shows de user a message. This is the piece the code that I am using to get the info from an item and fill it on DataGridView.
Private Sub cbExtensão_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbExtensão.SelectedIndexChanged
If cbExtensão.Visible <> cbExtensão.V(rbPorData.Checked & rbPorExtensão.Checked & rbPorNome.Checked) Then
If rbPorData.Checked Then
DataGridView2.DataSource = FillDataGridViewData(cbExtensão.Text)
ElseIf rbPorExtensão.Checked Then
DataGridView2.DataSource = FillDataGridViewExtensao(cbExtensão.Text)
ElseIf rbPorNome.Checked Then
DataGridView2.DataSource = FillDataGridViewName(cbExtensão.Text)
End If
Else
MsgBox("Please, check an option to search")
End If
End Sub
What I am trying to do is making something with this line If cbExtensão.Visible <> cbExtensão.V(rbPorData.Checked & rbPorExtensão.Checked & rbPorNome.Checked) Then but I've tried a lot of things and I can«t get anything from there. Basically I want it to displays a message if user doens't select any RadioButton after click on an item from CheckBox
this is how I have done it for my code.
Private Sub UserMsgBox(ByVal sMsg As String)
Dim sb As New StringBuilder()
Dim oFormObject As System.Web.UI.Control
sMsg = sMsg.Replace("'", "\'")
sMsg = sMsg.Replace(Chr(34), "\" & Chr(34))
sMsg = sMsg.Replace(vbCrLf, "\n")
sMsg += "<script language=javascript "
sMsg += "type=text/" + "javascript" + ">"
smsg += "alert ('" + "Please click on a code type" + "')"
sMsg += "</" + "script" + ">"
sb = New StringBuilder()
sb.Append(sMsg)
Page.RegisterclientScriptBlock("clientScript", sMsg)
For Each oFormObject In Me.Controls
If TypeOf oFormObject Is HtmlForm Then
Exit For
End If
Next
' Add the javascript after the form object so that the
' message doesn't appear on a blank screen.
oFormObject.Controls.AddAt(oFormObject.Controls.Count, New LiteralControl(sb.ToString()))
end sub
As Plutonix mentionned in the comments, you can just remove the first if statement...
Private Sub cbExtensão_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbExtensão.SelectedIndexChanged
If rbPorData.Checked Then
DataGridView2.DataSource = FillDataGridViewData(cbExtensão.Text)
ElseIf rbPorExtensão.Checked Then
DataGridView2.DataSource = FillDataGridViewExtensao(cbExtensão.Text)
ElseIf rbPorNome.Checked Then
DataGridView2.DataSource = FillDataGridViewName(cbExtensão.Text)
Else
MsgBox("Please, check an option to search")
End If
End Sub
So if no box is selected, it will fall down to the Else statement.

vb.net change combobox options depending on selected item in 2 previous comboboxes

I am creating a program which someone can input a search into a textbox and then narrow down the results using a series of comboboxes (or just use the comboboxes to search through everything).
The program looks like this: form 1
I have made the options in the 2nd combobox change using the following code:
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim type As String = ComboBox1.SelectedItem
Dim make As String = ComboBox2.SelectedItem
Dim model As String = ComboBox3.SelectedItem
Dim version As String = TextBox2.Text
Dim memory As String = TextBox3.Text
Dim problem As String = TextBox4.Text
Dim casenumber As Integer = Int(Rnd() * 9999) + 1000
If type = "Phone" Then
ComboBox2.Items.Clear()
Dim file As New System.IO.StreamReader("E: \phone.txt")
For i = 1 To 20
q(i) = file.ReadLine() & vbNewLine
ComboBox2.Items.Add(q(i))
Next
ElseIf type = "Tablet" Then
ComboBox2.Items.Clear()
Dim file As New System.IO.StreamReader("E:\tablet.txt")
For i = 1 To 20
q(i) = file.ReadLine() & vbNewLine
ComboBox2.Items.Add(q(i))
Next
ElseIf type = "Desktop computer" Then
ComboBox2.Items.Clear()
Dim file As New System.IO.StreamReader("E:\pc.txt")
For i = 1 To 20
q(i) = file.ReadLine() & vbNewLine
ComboBox2.Items.Add(q(i))
Next
ElseIf type = "Laptop" Then
ComboBox2.Items.Clear()
Dim file As New System.IO.StreamReader("E:\laptop.txt")
For i = 1 To 20
q(i) = file.ReadLine() & vbNewLine
ComboBox2.Items.Add(q(i))
Next
'Else
'Dim objwriter As System.IO.StreamWriter
'objwriter = My.Computer.FileSystem.OpenTextFileWriter("E:\unknown.txt", True)
'File.AppendText("type:" And ComboBox1.Text And "make" & ComboBox2.Text And "model: " & ComboBox3.Text And "version: " And TextBox2.Text & "memory" And TextBox3.Text)
End If
End Sub
However,the code won't work to change what is in the 3rd box. I have repeated the following code for each option:
Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox3.SelectedIndexChanged
Dim type As String = ComboBox1.SelectedItem
Dim make As String = ComboBox2.SelectedItem
Dim model As String = ComboBox3.SelectedItem
Dim version As String = TextBox2.Text
Dim memory As String = TextBox3.Text
Dim problem As String = TextBox4.Text
If type = "Phone" Then
If make = "apple" Then
ComboBox2.Items.Clear()
Dim file As New System.IO.StreamReader("E:\apple.txt")
For i = 1 To 20
q(i) = file.ReadLine() & vbNewLine
ComboBox3.Items.Add(q(i))
Next
ElseIf make = "samsung" Then
ComboBox2.Items.Clear()
Dim file As New System.IO.StreamReader("E:\samsung.txt")
For i = 1 To 20
q(i) = file.ReadLine() & vbNewLine
ComboBox3.Items.Add(q(i))
Next
ElseIf make = "htc" Then
ComboBox2.Items.Clear()
Dim file As New System.IO.StreamReader("E:\htc.txt")
For i = 1 To 20
q(i) = file.ReadLine() & vbNewLine
ComboBox3.Items.Add(q(i))
Next
ElseIf make = "Nokia" Then
ComboBox2.Items.Clear()
Dim file As New System.IO.StreamReader("E:\Nokia.txt")
For i = 1 To 20
q(i) = file.ReadLine() & vbNewLine
ComboBox3.Items.Add(q(i))
Next
ElseIf make = "Blackberry" Then
ComboBox2.Items.Clear()
Dim file As New System.IO.StreamReader("E:\blackberry.txt")
For i = 1 To 20
q(i) = file.ReadLine() & vbNewLine
ComboBox3.Items.Add(q(i))
Next
I have checked the obvious problems like putting the wrong text file names and capital letters etc, but can't get this to work whatever I do.
Does anyone know why the third combobox remains blank even when both conditions are met (both combobox1 and 2 have the right thing selected)? Any suggestion would be much appreciated.
Firstly I suspect that this code :-
Dim type As String = ComboBox1.SelectedItem.ToString
Dim make As String = ComboBox2.SelectedItem.ToString
Dim model As String = ComboBox3.SelectedItem.ToString
Dim version As String = TextBox2.Text
Dim memory As String = TextBox3.Text
Dim problem As String = TextBox4.Text
shouldn't be in each if your events. They should really be placed somewhere that executes after all the information has been chosen yes?
OK for a start paste this into a text file called "device type.txt"
Phone,E:\phone.txt
Tablet,E:\tablet.txt
Desktop Computer,E:\pc.txt
Laptop,E:\laptop.txt
Then edit your phones.txt file and the rest of the above files to match that format e.g this phone.txt file
Apple,E:\apple.txt
Samsung,E:\samsung.txt
Htc,E:\htc.txt
Nokia,E\nokia.txt
Blackberry,E:\blackberry.txt
and so on for each item that links to another file. For the last files in the tree - which I presume are the files containing a list of the models for each brand of phone, just leave them as a simple list. No commas or anything after each model.
Use this code to do the populating of each ComboBox
Private Sub PopulateComboBox(ByRef cboBox As ComboBox, ByVal itemSource As String)
RemoveHandler ComboBox1.SelectedIndexChanged, AddressOf ComboBox1_SelectedIndexChanged
RemoveHandler ComboBox2.SelectedIndexChanged, AddressOf ComboBox2_SelectedIndexChanged
RemoveHandler ComboBox3.SelectedIndexChanged, AddressOf ComboBox3_SelectedIndexChanged
Dim devices As New List(Of item)
Dim csvFlag As Boolean = False
cboBox.Items.Clear()
Using MyReader As New Microsoft.VisualBasic.
FileIO.TextFieldParser(itemSource)
If MyReader.ReadLine.Contains(",") Then csvFlag = True
End Using
Using MyReader As New Microsoft.VisualBasic.
FileIO.TextFieldParser(itemSource)
If csvFlag Then
MyReader.TextFieldType = FileIO.FieldType.Delimited
MyReader.SetDelimiters(",")
End If
Dim currentRow As String() = {"", ""}
While Not MyReader.EndOfData
Try
If csvFlag Then
currentRow = MyReader.ReadFields()
Dim tempItem As New item
tempItem.item = currentRow(0)
tempItem.fileName = currentRow(1)
devices.Add(tempItem)
Else
currentRow(0) = MyReader.ReadLine
Dim tempItem As New item
tempItem.item = currentRow(0)
tempItem.fileName = ""
devices.Add(tempItem)
End If
Catch ex As Microsoft.VisualBasic.
FileIO.MalformedLineException
MsgBox("Line " & ex.Message & "is not valid and will be skipped.")
End Try
End While
End Using
If csvFlag Then
cboBox.DataSource = devices
cboBox.DisplayMember = "item"
cboBox.ValueMember = "fileName"
Else
cboBox.DataSource = devices
cboBox.DisplayMember = "item"
cboBox.ValueMember = "item"
End If
AddHandler ComboBox1.SelectedIndexChanged, AddressOf ComboBox1_SelectedIndexChanged
AddHandler ComboBox2.SelectedIndexChanged, AddressOf ComboBox2_SelectedIndexChanged
AddHandler ComboBox3.SelectedIndexChanged, AddressOf ComboBox3_SelectedIndexChanged
End Sub
What it does is firstly check to see if the file being read is a comma-delimited file.
If it is delimited, it will read the file referred to in itemSource and expect a pair of values. The first value is what you see in the box(the DisplayMember), and the second value is what clicking on the box actually returns(the ValueMember)
If the file isn't comma-delimited, it will just read each line and add it to the combobox so that it acts normally (this will be important for the last files in the tree)
Next you need these methods for the ComboBoxes
Private Sub PopulateComboBox1()
PopulateComboBox(ComboBox1, "E:\device type.txt")
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
PopulateComboBox(ComboBox2, ComboBox1.SelectedValue.ToString)
End Sub
Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
PopulateComboBox(ComboBox3, ComboBox2.SelectedValue.ToString)
End Sub
Private Sub ComboBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox3.SelectedIndexChanged
PopulateComboBox(ComboBox3, ComboBox2.SelectedValue.ToString)
End Sub
Call the method to populate Combobox1 possibly in the form's load event.

vb.net Searching for specific lines within large .log files

I'm reading from 1-5mb log files outputting to a textview and also searching for specific lines outputting to another textview. Currently it takes about a minute for just a 1mb file. Does anyone know any faster methods of searching through lines or strings other than the method I'm using?
Imports EnterpriseDT.Net.Ftp
Public Class Form1
Private Sub SettingsToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles SettingsToolStripMenuItem.Click
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
Dim sw As New Stopwatch
Dim FullLine As String = ""
Dim ScriptLine As String = ""
sw.Start()
Dim ll As New Queue(Of String)
Dim i As String = ""
Using TestFile As New IO.StreamReader("c:\test.txt", System.Text.Encoding.Default, False, 4096)
Using OutFile As New IO.StreamWriter("c:\SBOutFile.txt", False, System.Text.Encoding.Default, 4096)
While TestFile.EndOfStream = False
i = TestFile.ReadLine
If i.Contains(".sqf") And i.Contains("handleGear.sqf") = False Then
ScriptLine = ScriptLine & i & vbNewLine & vbNewLine
FullLine = FullLine & i & vbNewLine & vbNewLine
Else
FullLine = FullLine & i & vbNewLine & vbNewLine
End If
End While
End Using
End Using
sw.Stop()
TextBox1.Text = FullLine
TextBox2.Text = ScriptLine
RichTextBox1.AppendText(String.Format("Run_Queue took {0} Milliseconds." & Environment.NewLine, sw.ElapsedMilliseconds))
End Sub
Private Sub Button1_Click_1(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Try
'connect to ftp server
Dim ftp As New FTPConnection
ftp.ServerAddress = "-"
ftp.ServerPort = "-"
ftp.UserName = "-"
ftp.Password = "-"
ftp.Connect()
ftp.ChangeWorkingDirectory("-")
ftp.TransferType = FTPTransferType.BINARY
'download a file
ftp.DownloadFile("c:\test.txt", "scripts.log")
'ftp.RenameFile("scripts.log", "scripts_test.log")
'close the connection
ftp.Close()
Catch ex As Exception
MessageBox.Show(ex.Message.ToString())
End Try
End Sub
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
End Sub
End Class
Given the heavy reading and concatenating you are doing as you're reading, I suspect its part of your time/performance issue. I would probably consider changing the declarations for ScriptLine and FullLine from String type to a StringBuilder, because Strings are technically immutable. That means each concatenation really turns out to be teardown of the previous object, and the creation of a new one in its place. StringBuilders are designed specifically for heavy concatenation scenarios. When the looping is finished, you can convert it back to a String.
Also, a compiled Regular Expression might search faster than String.Contains. Your regular expression string would be something like "(?!handleGear).sqf", meaning "find any sequence of zero or more characters other than "handleGear" in front of the string ".sqf".
I haven't had a chance to test that expression, so it is offered with that caveat. If I get a chance to throw together a test, I'll be glad to amend and let you know.
Good luck!
I just wanted to post what I came up with in the end. It was a very large improvement to what I had.
'Read file
Dim sw As New Stopwatch
Dim FullLine As String = ""
Dim ScriptLine As String = ""
sw.Start()
Dim ll As New Queue(Of String)
Dim i As String = ""
Dim builder As New StringBuilder
Using TestFile As New IO.StreamReader("c:\test.txt", System.Text.Encoding.Default, False, 4096)
builder.AppendLine("Started at: " & DateTime.Now.ToLongTimeString().ToString)
RichTextBox1.AppendText(Now.ToShortTimeString & " Reading Log File Started" & vbNewLine)
RichTextBox1.SelectionStart = RichTextBox1.TextLength
Dim rowCount As Integer = 0
Do Until TestFile.EndOfStream
ScriptLine = TestFile.ReadLine
ScriptLine = LCase(ScriptLine)
If InStr(ScriptLine, ".sqf") > 0 And InStr(ScriptLine, "handlegear.sqf") < 1 Then 'And InStr(ScriptLine, "createmarkerlocal.sqf") < 1 And InStr(ScriptLine, "setmarkerposlocal.sqf") < 1
builder.AppendLine(ScriptLine)
builder.AppendLine()
End If
rowCount = rowCount + 1
Loop
builder.AppendLine(Now.ToShortTimeString & "==== Searched " & rowCount & " rows" & vbNewLine)
builder.AppendLine(Now.ToShortTimeString & " Finished" & vbNewLine)
End Using
sw.Stop()
RichTextBox2.AppendText(builder.ToString & vbNewLine)
RichTextBox1.AppendText(Now.ToShortTimeString & String.Format(" Run_Queue took {0} Milliseconds." & Environment.NewLine, sw.ElapsedMilliseconds))

IMAPI2 in VB 2008 progress bar

I start making program that will burn CD/DVDs, and everything is okay.
I found way to burn with IMAPI2 API, but now I have problem:
I can't get progress bar of that burning.
Here is code:
Dim CDD1 As New IMAPI2.MsftDiscMaster2
Dim CDD2 As New IMAPI2.MsftDiscRecorder2
Dim FSI As New IMAPI2FS.MsftFileSystemImage
Dim CDD3 As New IMAPI2.MsftDiscFormat2Data
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Index = 0
Dim UniqueID = ""
Dim Directory
Dim Path = "C:\lll"
Dim result
Dim Stream
Label1.Text = "----- Started -----."
UniqueID = CDD1.Item(Index)
Label1.Text = Label1.Text & vbCrLf & "ID found: " & UniqueID
CDD2.InitializeDiscRecorder(UniqueID)
Label1.Text = Label1.Text & vbCrLf & "Recorder selected!"
Directory = FSI.Root
Label1.Text = Label1.Text & vbCrLf & "Directory is here: " & Directory.ToString
CDD3.Recorder = CDD2
Label1.Text = Label1.Text & vbCrLf & "Recorder 2 selected!"
CDD3.ClientName = "IMAPI2 TEST"
Label1.Text = Label1.Text & vbCrLf & "Client Name Selected!"
FSI.ChooseImageDefaults(CDD2)
Label1.Text = Label1.Text & vbCrLf & "Default selected!"
Directory.AddTree(Path, False)
Label1.Text = Label1.Text & vbCrLf & "Directory added!"
result = FSI.CreateResultImage()
Stream = result.ImageStream
Label1.Text = Label1.Text & vbCrLf & "Writing content to disc..."
If (CDD3.IsCurrentMediaSupported(CDD2) = True) Then
If (CDD3.IsRecorderSupported(CDD2) = True) Then
CDD3.Write(Stream)
Else
MsgBox("Not Suported Recorder!")
End If
Else
MsgBox("Not Suported Media!")
End If
Label1.Text = Label1.Text & vbCrLf & "----- Finished -----"
End Sub
When command
CDD3.Write(Stream)
is triggered, program freeze, and don't respond until data is burned completely.
Is there any way to stop this, to stop program freezing and enabling progress bar?
Thanks.
You need to use threading. So in your button click event handler you start off a new thread that does the actual burning and while that's going on in it's separate thread, the main thread can continue to update the GUI (including your progress bar).
See Thread.Start for a simple sample and if you want further information I'd suggest starting here: Managed Threading