I have tried to follow jmcilhinney's post at http://www.vbforums.com/showthread.p...Worker-Threads
I have a thread that relies on functions/subs that exist inside a module (I know people do not like modules since everything is pretty much public...but humor me :) )
The module has a sub that is supposed to write text to a textbox on the gui thread. That sub will be ran from another thread that is running the logic\processing, and not the gui thread. I was using delegates and checking for invokeRequired on the textbox before invoking the sub, but it just seems to do nothing. no errors, just nothing.
My code snippets are as follows:
Code in Module
---------------------
frmMain is the ....main form lol, on the gui.
It seems weird because it looks like I am following the process in that post above....but nothing happens even when i purposely call the logErrors sub from the logic/processing thread.
Any help would be greatly appreciated!
I have a thread that relies on functions/subs that exist inside a module (I know people do not like modules since everything is pretty much public...but humor me :) )
The module has a sub that is supposed to write text to a textbox on the gui thread. That sub will be ran from another thread that is running the logic\processing, and not the gui thread. I was using delegates and checking for invokeRequired on the textbox before invoking the sub, but it just seems to do nothing. no errors, just nothing.
My code snippets are as follows:
Code in Module
---------------------
Code:
Public Delegate Sub WriteTo_txtLog_Invoker(ByVal LogEntry As String) 'DECLARED WITHIN MODULE BEFORE SUBS
Public Sub LogErrors(ByVal ErrMsg As String)
'TODO: handle writing error to file
'Write error to GUI TextBox
WriteTo_txtLog(ErrMsg)
End Sub
Public Sub WriteTo_txtLog(ByVal LogEntry As String)
If frmMain.txtLog.InvokeRequired = True Then
frmMain.txtLog.Invoke(New WriteTo_txtLog_Invoker(AddressOf WriteTo_txtLog), LogEntry)
Else
frmMain.txtLog.Text = LogEntry & frmMain.txtLog.Text
End If
End SubIt seems weird because it looks like I am following the process in that post above....but nothing happens even when i purposely call the logErrors sub from the logic/processing thread.
Any help would be greatly appreciated!