Hi Herfried, hope your exam went well.
I attempted to impliment a Method Invoke to display MsgBox'sw from my
thread. Here is what I did...
I 1st declared a Delegate in a Module called Common.vb...
Public Delegate Function MsgBoxInvoke(ByVal szMsg As String, ByVal buttons
As Microsoft.VisualBasic.MsgBoxStyle, ByVal szTitle As String) As
Microsoft.VisualBasic.MsgBoxResult
Public MsgBoxScriptor As MsgBoxInvoke
In my main Form I added the Mothod:
Private Function MsgBoxInvoke(ByVal szMsg As String, ByVal buttons As
Microsoft.VisualBasic.MsgBoxStyle, ByVal szTitle As String) As
Microsoft.VisualBasic.MsgBoxResult
MsgBoxInvoke = MsgBox(szMsg, buttons, szTitle)
End Function
In Form.Load() I added...
Common.MsgBoxScriptor = New MsgBoxInvoke(AddressOf Me.MsgBoxInvoke)
In my thread I call...
Common.MsgBoxScriptor.Invoke("Test Msg", MsgBoxStyle.Exclamation, "Title")
When run, the MsgBox comes up, but if I click on the Form it still gets
hidden.
Am I doing this wrong?
RML
"Herfried K. Wagner [MVP]" wrote:
"RML" <RM*@discussions.microsoft.com> schrieb: I have never used Control.Invoke. How do I use this in my
thread to call the new form method. Do I need to create a Delegate, and
use
the Delegate to Invoke the new form mothod?
I have to learn for an exam today, so I am not able to write an example.
However, you will find information on multithreading and Windows Forms here:
Multithreading in Windows Forms applications
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=multithreading&lang=en>
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>