Results 1 to 39 of 39

Thread: background worker progress changed

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Angry background worker progress changed

    Hi,

    I'm having trouble getting the string from progress changed in bgw.

    Well, when i type the following code it works:
    HTML Code:
    msgbox(e.userstate)
    In this case i get the progress changed (string value)

    But if i write in progresschanged :

    HTML Code:
    text1.text=e.userstate.tostring
    i get nothing...

    this is how i send data to reportprogress:

    HTML Code:
    WorkerL.ReportProgress(10, "string")
    Any ideas?


    Cheers!
    Thanks for helping me out.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: background worker progress changed

    bump?
    Thanks for helping me out.

  3. #3
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: background worker progress changed

    I created this simple test and it works as advertised.
    Code:
        Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
            BackgroundWorker1.ReportProgress(10, "string")
        End Sub
    
        Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
            TextBox1.Text = DirectCast(e.UserState, String)
        End Sub
    The UserState is an object.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  4. #4
    Addicted Member
    Join Date
    Oct 2012
    Location
    Springfield, IL
    Posts
    142

    Re: background worker progress changed

    Is you code ever calling the WorkerL.ReportProgress(10, "string") portion of your code? Set a breakpoint on that line and see if it ever hits it.

    You might need to provide more details of how your code works. From what you posted it looks like it should work but obviously you are missing something if its not, but i cant tell from what information you provided.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: background worker progress changed

    Thanks for the reply...

    This is what i do:

    start worker and calling a function in _DoWork ... that same function reports progress to the worker...which gets the reported progress and shows it in a message box but it wont show it in text box or any other form :/

    So, if i put in ProgressChanged something like :
    msgbox (e.userstate)
    i will get the the reported string ....

    otherwise it wont work...i really don't know why
    Thanks for helping me out.

  6. #6
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: background worker progress changed

    Quote Originally Posted by batori View Post
    Thanks for the reply...

    This is what i do:

    start worker and calling a function in _DoWork ... that same function reports progress to the worker...which gets the reported progress and shows it in a message box but it wont show it in text box or any other form :/

    So, if i put in ProgressChanged something like :


    i will get the the reported string ....

    otherwise it wont work...i really don't know why
    What? Dowork calls a function that reports progress? I am confused.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: background worker progress changed

    Ok, let me explain in a better way.

    So,

    Code:
     Private Sub WorkerL_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles WorkerL.DoWork
    
           CALCULATE_NUMBERS(selected_numbers)
        End Sub
    Code:
     Private Sub WorkerL_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles WorkerL.ProgressChanged
        ' this code works, shows the state (string)
            MsgBox(e.UserState)
       'this code below returns nothing
            txtDebug.Text = DirectCast(e.UserState, String)
    
        End Sub
    Code:
    Public Function CALCULATE_NUMBERS(num as integer)
    ' Do some work
    frmMain.WorkerL.ReportProgress(10, "string")
    End Fucntion
    Thanks for helping me out.

  8. #8
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: background worker progress changed

    Have you actually set WorkerReportsProgress to true?

  9. #9
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: background worker progress changed

    You do realize your not actually reporting any progress.

    Using the BackgroundWorker Component

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: background worker progress changed

    Yes, of course it is.

    I'm even getting a message box when progress is "triggered" ... it's just that i cant get that userstate to a textbox or label...i can only get it in a message box form...isn't that strange??

    Thanks for helping me out.

  11. #11
    PowerPoster
    Join Date
    Oct 2010
    Posts
    2,141

    Re: background worker progress changed

    I don't think we are seeing the whole picture here, but just for grins as giggles, try replacing the code in the progress handler with this:

    Code:
          If InvokeRequired Then
             MsgBox("Progress from wrong thread")
             Me.Invoke(New Action(Of Object, System.ComponentModel.ProgressChangedEventArgs)(AddressOf WorkerL_ProgressChanged), New Object() {sender, e})
          Else
             Text1.Text = e.UserState.ToString
          End If
    and let us know what happens.

  12. #12
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: background worker progress changed

    Quote Originally Posted by batori View Post
    Ok, let me explain in a better way.

    So,

    Code:
     Private Sub WorkerL_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles WorkerL.DoWork
    
           CALCULATE_NUMBERS(selected_numbers)
        End Sub
    Code:
     Private Sub WorkerL_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles WorkerL.ProgressChanged
        ' this code works, shows the state (string)
            MsgBox(e.UserState)
       'this code below returns nothing
            txtDebug.Text = DirectCast(e.UserState, String)
    
        End Sub
    Code:
    Public Function CALCULATE_NUMBERS(num as integer)
    ' Do some work
    frmMain.WorkerL.ReportProgress(10, "string")
    End Fucntion
    When I run this
    Code:
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            BackgroundWorker1.WorkerReportsProgress = True
            BackgroundWorker1.RunWorkerAsync()
        End Sub
    
        Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
            why()
        End Sub
    
        Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
            TextBox1.Text = DirectCast(e.UserState, String)
        End Sub
    
        Private Sub why()
            BackgroundWorker1.ReportProgress(10, "string")
        End Sub
    The "string" appears in the textbox. Try removing frmMain from this frmMain.WorkerL.ReportProgress(10, "string")
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: background worker progress changed

    I tried TnTinMN method , it did not show anything....
    I tried dbasnett method , and it worked....

    So , what i did, i moved the Function from being Public in the module, to being Public in frmMain and then.....it works!

    But then again...when i had the function in the module, the progress did "arrive" to frmmain, and it was shown in the msgbox but not in any other textbox. label or whatsoever....but having a public function , in the frmMain code...worked.

    But i still don't get it...
    Thanks for helping me out.

  14. #14
    Addicted Member
    Join Date
    Oct 2012
    Location
    Springfield, IL
    Posts
    142

    Re: background worker progress changed

    Quote Originally Posted by batori View Post
    I tried TnTinMN method , it did not show anything....
    I tried dbasnett method , and it worked....

    So , what i did, i moved the Function from being Public in the module, to being Public in frmMain and then.....it works!

    But then again...when i had the function in the module, the progress did "arrive" to frmmain, and it was shown in the msgbox but not in any other textbox. label or whatsoever....but having a public function , in the frmMain code...worked.

    But i still don't get it...
    The reason is that a MODULE has global scope and simply calling frmMain is referencing the TYPE of form frmMain and not the instantiated form. I suppose if you prefixed frmMain with My.Forms.frmMain then it would work in the module but you did the right thing by moving your function to the form.
    Last edited by OICU812; Mar 21st, 2014 at 10:07 AM.

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: background worker progress changed

    I tried your suggestion to use my.forms.frmMain...still does not work ...

    i can only get the string in progresschanged by using MSGBOX .... as usual....

    i still dont get it ....
    Thanks for helping me out.

  16. #16
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: background worker progress changed

    Did you try
    WorkerL.ReportProgress(10, "string")
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: background worker progress changed

    yes, with both my.forms.frmmain.workerl and with frmmain.workerL...

    progresschanged is triggered and msgbox return the value...but nothing else does.... ???? :/
    Thanks for helping me out.

  18. #18
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: background worker progress changed

    So out of curiosity I tried this

    Code:
    Public Class Form1
        Public WithEvents BackgroundWorker1 As New System.ComponentModel.BackgroundWorker
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            BackgroundWorker1.WorkerReportsProgress = True
            BackgroundWorker1.RunWorkerAsync()
        End Sub
    
        Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
            Do While True
                why()
                Threading.Thread.Sleep(1000)
            Loop
        End Sub
    
        Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
            TextBox1.Text = DirectCast(e.UserState, String) & " " & e.ProgressPercentage.ToString
        End Sub
    
        Private Sub why()
            BackgroundWorker1.ReportProgress(10, DateTime.Now.ToString("HH:mm:ss.f"))
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            test()
        End Sub
    End Class
    
    
    Module Module1
        Public Sub test()
            Form1.BackgroundWorker1.ReportProgress(20, "TEST")
        End Sub
    
    End Module
    Works, but I personally don't like using the default instance.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  19. #19
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: background worker progress changed

    Ok... hold on... I'm completely confused... if the process that's doing the work is in a module, that should be fine... the UI should only be updated in the ReportProgress event, which should be back on the main form... so... there shouldn't be any need to access the instance let alone the default instance...

    I'm beyond a little confused here...

    @Batori - It might help if you posted your ACTUAL code... not bits and pieces... but the actual code.... all of the BGW events, plus how you're starting it, how you're opening the form, and your module code that is doing the work.


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  20. #20
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: background worker progress changed

    Ok... I see the problem... in the sub, you need a reference to the BGW in order to call it's report process method... simple... pass it in...

    Code:
    Public Function CALCULATE_NUMBERS(num as integer, someBGW as BackGroundWorker)
    ' Do some work
        someBGW.ReportProgress(10, "string")
    End Fucntion

    Code:
     Private Sub WorkerL_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles WorkerL.DoWork
    
           CALCULATE_NUMBERS(selected_numbers, WorkerL)
        End Sub
    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  21. #21
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: background worker progress changed

    Why is the backgroundworker not located on the form any way.

  22. #22
    Member
    Join Date
    Jun 2013
    Location
    KiwiLand
    Posts
    44

    Re: background worker progress changed

    Don't forget, if you are accessing a control outside of the thread it was created on you SHOULD be using a delegate to update that control!

    First things first make sure the backgroundworker is correctly configured to report progress.
    In the dowork event reference the background worker and call the reportprogress function.
    (Percentages are calculated easily via NumberProcessed / NumberTotal * 100)
    In the backgroundworker reportprogress event reference a delegate IF accessing a "foreign" control:
    Example
    Code:
    Public Sub MyUpdateControlInvoke(Byval MyProperty As SomePropertyType)
    	If MyControl.InvokeRequired Then
    		MyControl.invoke(New MyUpdateControlDelegate(AddressOf MyUpdateControlInvoke), MyProperty)
    	Else
    		MyControl.Value = MyProperty
    	End If
    End Sub
    
    Public Delegate Sub MyUpdateControlDelegate(Byval MyProperty As SomePropertyType)
    You can then use this delegate to access a control no matter what thread you start by using:
    Code:
    MyUpdateControlInvoke(MyProperty)
    Hope this makes sense

  23. #23

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: background worker progress changed

    @ident ... it is.

    @tg...i will try what you suggest!


    EDIT:

    @tg...i tried your last solution but still it did not work ... i still get the string in a msgbox but not in a textbox, label, ecc...
    the first soulition has been tried to but with my function, and in that case it does the calculating but it does not give the reporting back.

    @duckles ... tried your solution, adding it to module but still, did not work ...

    I noticed that even if i put the following code in ProgressChanged ... it won't display it .. but again, a message box will!
    I even tried to display progress percentage...still, no luck ... only a msgbox will display the progress percentage.

    Code:
     txtDebug.Text = "test"
    Last edited by batori; Mar 22nd, 2014 at 02:58 AM.
    Thanks for helping me out.

  24. #24
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: background worker progress changed

    Read Johns articles on managing data with multiple forms and default form instances

    http://jmcilhinney.blogspot.co.uk/

    We are trying to help you yet you avoid answers. Why does it need to be in a module.

  25. #25
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: background worker progress changed

    Quote Originally Posted by duckles View Post
    Don't forget, if you are accessing a control outside of the thread it was created on you SHOULD be using a delegate to update that control!

    First things first make sure the backgroundworker is correctly configured to report progress.
    In the dowork event reference the background worker and call the reportprogress function.
    (Percentages are calculated easily via NumberProcessed / NumberTotal * 100)
    In the backgroundworker reportprogress event reference a delegate IF accessing a "foreign" control:
    Example
    Code:
    Public Sub MyUpdateControlInvoke(Byval MyProperty As SomePropertyType)
        If MyControl.InvokeRequired Then
            MyControl.invoke(New MyUpdateControlDelegate(AddressOf MyUpdateControlInvoke), MyProperty)
        Else
            MyControl.Value = MyProperty
        End If
    End Sub
    
    Public Delegate Sub MyUpdateControlDelegate(Byval MyProperty As SomePropertyType)
    You can then use this delegate to access a control no matter what thread you start by using:
    Code:
    MyUpdateControlInvoke(MyProperty)
    Hope this makes sense
    No. The whole point of the BGW is to make threading and delegation easy. Also there is no need to create your own custom delegate. You would never invoke like this using the BGW.

    Side point since no custom delegate is needed.

    vb Code:
    1. Public Class Form1
    2.  
    3.     Public Sub MyUpdateControlInvoke(ByVal MyProperty As SomePropertyType)
    4.         Me.Invoke(Sub() MyControl.Value = MyProperty)
    5.     End Sub
    6.  
    7. End Class

    or if you wanted to check invoke needed.

    vb Code:
    1. Public Class Form1
    2.  
    3.     Public Class SomePropertyType
    4.  
    5.     End Class
    6.  
    7.     Public Sub MyUpdateControlInvoke(ByVal MyProperty As SomePropertyType)
    8.         If Me.InvokeRequired Then
    9.             Me.Invoke(New Action(Of SomePropertyType)(AddressOf MyUpdateControlInvoke))
    10.         Else
    11.             ' what ever
    12.         End If
    13.     End Sub
    14.  
    15. End Class

  26. #26
    Member
    Join Date
    Jun 2013
    Location
    KiwiLand
    Posts
    44

    Re: background worker progress changed

    Batori: Please clarify.

    Are you trying to get a progress percentage OR are you trying to display a progress "step"?
    Also:
    Code:
        Private Sub why()
            BackgroundWorker1.ReportProgress(10, DateTime.Now.ToString("HH:mm:ss.f"))
        End Sub
    Should be inside of the DoWork event.

    Please clarify further.

  27. #27

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: background worker progress changed

    Well, i'm having that function in a module because im used to have functions there and not "mess up" with my form code.

    @duckles , withing your code i'm trying to get

    Code:
    DateTime.Now.ToString("HH:mm:ss.f")
    which equals

    Code:
    e.UserState
    and i really do get that part of a code but only in a msgbox in frmMain.

    ..out of curiosity i tried to get in a textbox something like

    Code:
    txtDebug.text =  e.ProgressPercentage
    and that too did not show in the textbox but only in a msgbox


    i could put the function in the main form code and then it would work, as tested ... but i'm not sure why it does work "partially" when the function is stored in a module, does give results in a msgbox and not in any other txtbox, label, ecc....

    @ident: how should i report then progress from a public function stored in a module when taht function is called from a background worker stored in the main form?

    edit:

    not even this works when put in progresschanged:

    Code:
    txtDebug.Text = txtDebug.Text & "test"
    Last edited by batori; Mar 22nd, 2014 at 08:23 PM.
    Thanks for helping me out.

  28. #28
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: background worker progress changed

    WHY IS IT IN A module. I guess you not bothered to read that last link i provided. Its so frustrating when im helping you and your sticking your fingers in your ears and saying "im not listening".

  29. #29

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: background worker progress changed

    It doesn't really matter what the function is...

    Code:
        Public Function CALCULATE_NUMBERS() As String
            Dim a As Integer = 0
            a = a + 1
            frmMain.WorkerL.ReportProgress(10, a)
    
        End Function
    Still the same thing when the function is stored in a module. Msgbox from frmMain WorkerL progresschanged gives the result back, txtbox and others...don't.

    I do get the result in a txtbox on RunWorkerCompleted but never on progresschanged.
    Thanks for helping me out.

  30. #30
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: background worker progress changed

    Quote Originally Posted by batori View Post
    Well, i'm having that function in a module because im used to have functions there and not "mess up" with my form code.
    1) put the function back in the form - there is zero reason for it to be in a module.
    2) there's no reason for it to be a function, it should be a sub - it doesn't even return anything.
    3) Just use bgw.ReportProgress... no need to specify the form or anything.
    4) You ReportProgress event should then work.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  31. #31

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: background worker progress changed

    By having the function/sub on the main form, everything works fine ....
    But , still....im interested why do i get the report in a msgbox and not in any other textbox , label, ecc ... i'm frustrated
    Thanks for helping me out.

  32. #32
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: background worker progress changed

    That last sentence touches on an important point and a source of confusion for some. There’s no point updating the default instance of a form class if you haven’t actually displayed the default instance of that class in the first place. This is one of the reasons I say that, if you’re going to use default instances at all, you should use them all the time. For instance, if you create a form and display it like this:


    Dim myForm As New SomeForm

    myForm.Show()


    then you can’t then refer to the default instance of the SomeForm class and expect the form on your screen to be affected. You’ve created one instance and displayed that, then the system creates the default instance. They are two different objects so making changes to one will not affect the other. If you’re going to make changes by referring to the default instance then you need to have displayed the default instance in the first place:

  33. #33

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: background worker progress changed

    ident, i really don't understand what are you saying...

    Regardless, i found a solution....still, having the function stored in a module!

    Here it is :

    Start with a button to trigger the worker...all in a form

    Code:
    Private Sub cmdSTART_Click(sender As Object, e As EventArgs) Handles  cmdSTART.Click
            WorkerL.ReportProgress(10, CALCULATE_NUMBERS)
    End Sub
    
    Private Sub WorkerL_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles WorkerL.DoWork
       CALCULATE_NUMBERS()
    End Sub
    
    Private Sub WorkerL_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles WorkerL.ProgressChanged
            txtDebug.Text = e.UserState
    End Sub
    ' function stored in module
    Code:
      Public Function CALCULATE_NUMBERS() As String
            Dim a As Integer = 0
            a = a + 1
            CALCULATE_NUMBERS = a
    
     End Function
    Thanks for helping me out.

  34. #34
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: background worker progress changed

    do you have any interest in learning?

  35. #35
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: background worker progress changed

    I don't see how that could possibly work...

    Wait.... oh my...

    Nope.... no... not gonna do it... I'm jsut going to bite my tongue... Not going to say anything further.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  36. #36
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: background worker progress changed

    does the op even look at any replys?

    2) there's no reason for it to be a function, it should be a sub - it doesn't even return anything.

  37. #37
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: background worker progress changed

    Don't know. No longer care. I'm unsubscribing from this thread. It's gone way too long for what should have been a simple issue with a simple fix.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  38. #38
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: background worker progress changed

    100% AGREE , un scribing also

  39. #39
    New Member
    Join Date
    Feb 2018
    Posts
    1

    Re: background worker progress changed

    @dbasnett - Thank you for the simple and effective approach to this problem. Old threads can indeed be useful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width