Advanced Thread Question

SIMIN

Regular
Joined
Mar 10, 2008
Messages
92
Hi,
I want to show a message box in a thread, so I cannot show it normally, I have to use this code:
Visual Basic:
    Private Delegate Sub MessageBoxHandler(ByVal Message As String, ByVal Style As MessageBoxIcon)
    Private Sub ShowMessageBox(ByVal Message As String, ByVal Style As MessageBoxIcon)
        MessageBox.Show(Message, My.Application.Info.AssemblyName, MessageBoxButtons.OK, Style)
    End Sub

...

usage inside thread:

Me.ShowMessageBox("???", MessageBoxIcon.Question)
OK that works well without any problem.
I just need to change it so I can have YesNoCancel buttons instead of OK.
I can simply change it in the Delegate but don't know how to get back the result in the usage code inside thread?
Can you please help me?
Thanks,
 
Thank you:)
I am not very familiar with those advanced thread options.
You mean something like:
Visual Basic:
    Private Delegate Function MessageBoxHandler(ByVal Message As String, ByVal Style As MessageBoxIcon) As DialogResult
    Private Function ShowMessageBox(ByVal Message As String, ByVal Style As MessageBoxIcon) As DialogResult
        MessageBox.Show(Message, My.Application.Info.AssemblyName, MessageBoxButtons.YesNoCancel, Style)
    End Function

...

aa = Me.ShowMessageBox("a", MessageBoxIcon.Question)
:confused:
 
Have you tried
Visual Basic:
Private Delegate Function MessageBoxHandler(ByVal Message As String, ByVal Style As MessageBoxIcon) As DialogResult

Private Function ShowMessageBox(ByVal Message As String, ByVal Style As MessageBoxIcon) As DialogResult
Return MessageBox.Show(Message, My.Application.Info.AssemblyName, MessageBoxButtons.YesNoCancel, Style)
End Function

...

aa = Me.ShowMessageBox("a", MessageBoxIcon.Question)
 
Back
Top