Backgroundwork + progressbar
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
6 posts
Page 1 of 1
So I have this code in backgroundwork2.dowork how can i show the progress of this in progressbar2
Code: Select all
thanksDim myJob As New Job2Convert()
Dim ms As New MediaServer()
myJob.pszSrcFile = "C:\Users\Devin\Desktop\Release\test.wmv" 'THE FILE TO CONVERT
myJob.pszDstFile = "C:\Users\Devin\Desktop\Release\test.avi" 'THE FILENAME TO SAVE IT AS
myJob.pszDstFormat = "avi" 'FORMAT TO CONVERT TOO
myJob.pszAudioCodec = "aac" 'AUDIO CODEC TO USE
myJob.nAudioChannels = 2
myJob.nAudioBitrate = -1
myJob.nAudioRate = -1
myJob.pszVideoCodec = "h264" 'VIDEO CODEC TO USE
myJob.nVideoBitrate = -1
myJob.nVideoFrameRate = -1
myJob.nVideoFrameWidth = -1
myJob.nVideoFrameHeight = -1
Dim ret As Boolean = ms.ConvertFile(myJob)
Insert the following code into the subroutine you want to start the process. I'm guessing it is a button so put it in the click event.
Should work like a charm. But remember, don't try to update controls when using this code. For example, don't try adding something to a listbox or update a progress bar. If you're trying to do that it gets a little more complicated.
Code: Select all
Just copy and paste this and delete your old code:
Dim Strt As System.Threading.Thread
Strt = New System.Threading.Thread(AddressOf MyThread1)
Strt.Start()
Code: Select all
Sub MyThread1()
Dim myJob As New Job2Convert()
Dim ms As New MediaServer()
myJob.pszSrcFile = "C:\Users\Devin\Desktop\Release\test.wmv" 'THE FILE TO CONVERT
myJob.pszDstFile = "C:\Users\Devin\Desktop\Release\test.avi" 'THE FILENAME TO SAVE IT AS
myJob.pszDstFormat = "avi" 'FORMAT TO CONVERT TOO
myJob.pszAudioCodec = "aac" 'AUDIO CODEC TO USE
myJob.nAudioChannels = 2
myJob.nAudioBitrate = -1
myJob.nAudioRate = -1
myJob.pszVideoCodec = "h264" 'VIDEO CODEC TO USE
myJob.nVideoBitrate = -1
myJob.nVideoFrameRate = -1
myJob.nVideoFrameWidth = -1
myJob.nVideoFrameHeight = -1
Dim ret As Boolean = ms.ConvertFile(myJob)
End Sub
Should work like a charm. But remember, don't try to update controls when using this code. For example, don't try adding something to a listbox or update a progress bar. If you're trying to do that it gets a little more complicated.
Thank you for your help. how can i show the progress of this in the progressbar?
thanks you again
thanks you again
You would most likely have to use a background worker instead. Check out this: http://www.java2s.com/Code/VB/GUI/Backg ... erDemo.htm
You would have to do a little rewrite of the code I gave you if you want to use this method. Try to avoid cross-thread errors. They can be a pain..
You would have to do a little rewrite of the code I gave you if you want to use this method. Try to avoid cross-thread errors. They can be a pain..
thanks yeh they can be a pain lol
thanks for your help again hope to return the help someday
thanks for your help again hope to return the help someday
If you have any problems then just post back on here and I will have a look at the code you've got.
6 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023