Writing to a control form another thread.

  • Thread starter Thread starter Brian Tkatch
  • Start date Start date
B

Brian Tkatch

Guest
I have an application that uses a multi-line textbox to show output. It also uses Titanium Proxy which writes to the textbox from one of the handlers. This is achieved via telling the log subroutine that it is on another thread and using invoke. It works well.

Sub Log_Message(Message As String, Optional Message_Is_From_Another_Thread As Boolean = False)

Debug.WriteLine(Message)

Message &= Environment.NewLine

If Message_Is_From_Another_Thread Then
' Ask the textbox to call for an update.
Log.Invoke(Sub() Log.AppendText(Message))
Else
Log.AppendText(Message)
End If

End Sub


I am now trying to add additional functionality to the code so that it can download another file. The same code in the same handler calls this same function, and hangs on the invoke (until, after a minute, Selenium times out). So i am trying to figure out where the new functionality differs from the existing functionality, and why this causes a hang on invoke.

There is an obvious difference in how they work. In the existing functionality, a button is clicked and a generated pdf is downloaded in a new tab (which Titanium usurps). In the new functionality, a button is clicked, but it reloads the same url with different html which itself includes an embedded pdf (which Titanium usurps).

If i comment out the invoke, all works fine. Please help me: what am i doing wrong?

Continue reading...
 
Back
Top