Event Handling - Progress Bar/Msg

stribbed

New member
Joined
Jun 13, 2007
Messages
2
Programming Experience
1-3
Forgive me for my ignorance in this matter. I am using .NET 1.1 and am trying to update a progress bar and message control in a form via some back-end code.
Here is my code for the message in the form class:
VB.NET:
Public Class frmMain
     Friend WithEvents MySender As New BusinessService

    Private Sub MySender_ProgressMsg(ByVal message As String) Handles MySender.ProgressMsg
        Me.lblProgress.Text = message
    End Sub

    'Other form controls events and setup
End Class

Here is my code that fires the message:
VB.NET:
Public Class BusinessService
    Public Event ProgressMsg(ByVal message As String)
    
    Sub StartProcessData()
        ProcessData()
    End Sub

    Public Function ProcessData() As Boolean
        RaiseEvent ProgressMsg("The data processing has begun.")

        ' Some other processing
    End Function
End Class

Not sure if its the way the code is being called in this instance as it is as a Thread:
VB.NET:
            With New System.Threading.Thread(AddressOf service.StartProcessData)
                .Start()
            End With

Hopefully someone can see what I am missing here.
 
I knew it would be something simple. I was not using the instance of the object that had the events attached. I was calling the main method with service rather than MySender.

Doh!
 
Back
Top