hi all, i have lurked on these forums before and finally signed up
i have a situation that, after days of searching the web, i have not been able to come up with a solution for.
i have to fire off a function that takes a large amount of time (writes to database, creates files, etc etc)
this function is a non-shared function of a class. if need be i could make it Shared.
since this is time consuming and locks up the UI, i am calling it via a delegate in a new thread.
this code is being called from another class's subroutine:
the code works great, but what i need to be able to do is update a form with a progress bar as the job is processing.
all of the examples i have seen that do this are being called from within a Windows Form and they access the form directly - i cant do that in this case. my form needs to be 1 form for 1 job being executed - can process multiple jobs at one time and thus i need multiple forms.
i have tried making the form part of my delegate class but since it runs in the same thread the effect is it "freezes" until the job is complete.
i have just started looking into using a background worker but again, all examples i have seen use the component as part of a form - that wont work for me.
any ideas? if anything is unclear please let me know!
i have a situation that, after days of searching the web, i have not been able to come up with a solution for.
i have to fire off a function that takes a large amount of time (writes to database, creates files, etc etc)
this function is a non-shared function of a class. if need be i could make it Shared.
since this is time consuming and locks up the UI, i am calling it via a delegate in a new thread.
VB.NET:
Public Class clsSendBatchDelegate
Private log As clsMailLogWithEmails = Nothing
Private WithEvents mm As clsMailManager = Nothing
Public Sub SendBatchToQueue()
'' this is the routine that takes a LONG time
mm.SendBatchToQueue(Me.log)
End Sub
Public Sub New(ByVal mmX As clsMailManager, ByVal logX As clsMailLogWithEmails)
Me.log = logX
Me.mm = mmX
End Sub
end class
this code is being called from another class's subroutine:
VB.NET:
Dim arg As New Managers.clsMailManager.clsSendBatchDelegate(mm, log)
thrd = New System.Threading.Thread(AddressOf arg.SendBatchToQueue)
thrd.Start()
the code works great, but what i need to be able to do is update a form with a progress bar as the job is processing.
all of the examples i have seen that do this are being called from within a Windows Form and they access the form directly - i cant do that in this case. my form needs to be 1 form for 1 job being executed - can process multiple jobs at one time and thus i need multiple forms.
i have tried making the form part of my delegate class but since it runs in the same thread the effect is it "freezes" until the job is complete.
i have just started looking into using a background worker but again, all examples i have seen use the component as part of a form - that wont work for me.
any ideas? if anything is unclear please let me know!