Click here to Skip to main content
15,906,329 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionproject sample book Pin
Dave Pursey3-Dec-08 14:06
Dave Pursey3-Dec-08 14:06 
AnswerRe: project sample book Pin
Christian Graus3-Dec-08 14:17
protectorChristian Graus3-Dec-08 14:17 
QuestionString as Executable Code Pin
User 54091903-Dec-08 13:03
User 54091903-Dec-08 13:03 
AnswerRe: String as Executable Code Pin
Christian Graus3-Dec-08 13:53
protectorChristian Graus3-Dec-08 13:53 
QuestionHow can I make this loading animation work right? Pin
ikantspelwurdz3-Dec-08 6:52
ikantspelwurdz3-Dec-08 6:52 
AnswerRe: How can I make this loading animation work right? Pin
Dave Kreskowiak3-Dec-08 6:59
mveDave Kreskowiak3-Dec-08 6:59 
GeneralRe: How can I make this loading animation work right? Pin
Luc Pattyn3-Dec-08 7:02
sitebuilderLuc Pattyn3-Dec-08 7:02 
GeneralRe: How can I make this loading animation work right? Pin
ikantspelwurdz3-Dec-08 8:24
ikantspelwurdz3-Dec-08 8:24 
Here's my current attempt to make it work using a background worker. Am I doing this wrong? Because it still stops responding under the same circumstances as when I do it single threaded:

Imports System.IO
Imports System.ComponentModel

Public Class Form1

    Private worker As System.ComponentModel.BackgroundWorker
    Private progress As Double


    Public Sub drawlazor(ByVal progress As Double)
        lazorbar.Size = New Size(lazorbar.Size.Width, 330 * progress)
        Refresh()

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Show()

        progress = 0

        worker = New System.ComponentModel.BackgroundWorker
        worker.WorkerReportsProgress = True
        worker.WorkerSupportsCancellation = True

        AddHandler worker.DoWork, New _
           DoWorkEventHandler(AddressOf OnWork)

        worker.RunWorkerAsync()
        While progress < 1
            System.Threading.Thread.Sleep(20)
            drawlazor(progress)
        End While
        worker.CancelAsync()


    End Sub

    Private Sub OnWork(ByVal sender As Object, _
                   ByVal e As DoWorkEventArgs)
        Dim oRead As New FileStream("file.bin", FileMode.Open)

        Dim index As Int64 = 0
        Dim filesize As Int64 = New FileInfo("file.bin").Length
        Dim count As Int32 = 1024 * 1024
        Dim oBuf(count) As Byte
        dostuff(oBuf)

        While index < filesize

            If (count > filesize - index) Then
                count = filesize - index
                Array.Resize(oBuf, count)
            End If

            oRead.Read(oBuf, 0, count)
            index += count

            progress = index / filesize

        End While

    End Sub

    Private Sub dostuff(ByVal oBuf() As Byte)
        ' pretend this is a parsing function that takes exactly 20ms to parse 1MB
        Threading.Thread.Sleep(20)
    End Sub
End Class

GeneralRe: How can I make this loading animation work right? Pin
Luc Pattyn3-Dec-08 8:50
sitebuilderLuc Pattyn3-Dec-08 8:50 
GeneralRe: How can I make this loading animation work right? Pin
ikantspelwurdz3-Dec-08 9:37
ikantspelwurdz3-Dec-08 9:37 
GeneralRe: How can I make this loading animation work right? Pin
Luc Pattyn3-Dec-08 10:07
sitebuilderLuc Pattyn3-Dec-08 10:07 
GeneralRe: How can I make this loading animation work right? Pin
Christian Graus3-Dec-08 8:52
protectorChristian Graus3-Dec-08 8:52 
QuestionEdit image in a text editor Pin
Gagan.203-Dec-08 4:39
Gagan.203-Dec-08 4:39 
AnswerRe: Edit image in a text editor Pin
Thomas Stockwell3-Dec-08 6:24
professionalThomas Stockwell3-Dec-08 6:24 
AnswerRe: Edit image in a text editor Pin
Christian Graus3-Dec-08 8:53
protectorChristian Graus3-Dec-08 8:53 
QuestionVBA Question Pin
EliottA3-Dec-08 2:59
EliottA3-Dec-08 2:59 
AnswerRe: VBA Question Pin
Dave Kreskowiak3-Dec-08 4:11
mveDave Kreskowiak3-Dec-08 4:11 
GeneralRe: VBA Question Pin
EliottA3-Dec-08 4:20
EliottA3-Dec-08 4:20 
QuestionHow to insert multiple checkbox value into database using VB Pin
sumit52833-Dec-08 1:30
sumit52833-Dec-08 1:30 
AnswerRe: How to insert multiple checkbox value into database using VB Pin
Guffa3-Dec-08 2:23
Guffa3-Dec-08 2:23 
GeneralRe: How to insert multiple checkbox value into database using VB Pin
sumit52833-Dec-08 18:50
sumit52833-Dec-08 18:50 
AnswerRe: How to insert multiple checkbox value into database using VB Pin
Nanda_MR3-Dec-08 22:02
Nanda_MR3-Dec-08 22:02 
Questionhelp with Antialiasing Pin
onlyehtisham3-Dec-08 0:46
onlyehtisham3-Dec-08 0:46 
GeneralRe: help with Antialiasing Pin
Luc Pattyn3-Dec-08 1:16
sitebuilderLuc Pattyn3-Dec-08 1:16 
GeneralRe: help with Antialiasing Pin
onlyehtisham3-Dec-08 7:05
onlyehtisham3-Dec-08 7:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.