MainForm.Invoke (New MethodInvoker(A ddressOf MainForm.Contro ls.Add))
Yeah that doesn't work and I know it's not what you told me to do, lol I'm
sorry. Its as if I am wanting to do this.
I have form1, it is going to do some calculations for a bit, I cannot escape
that fact as form1 is my main application form. What I want to do is create
a new thread that will add a control to form1 (that covers the entire form)
and display a bussy animation. Problem is VB wont let me add a control to a
form on a different thread. I'm certain what you gave me will work I guess
I just do not understand what I am supposed to do.
This is my code, Mainform is essentially form1 as described above.
'simple code to display bussy notification
Public mrg_p As wait
Private t As Threading.Threa d
Public Sub show_bussy()
t = New Threading.Threa d(AddressOf bussy)
t.Start()
End Sub
Private Sub bussy()
If mrg_p IsNot Nothing Then mrg_p.Dispose()
mrg_p = New wait
'MainForm.Contr ols.Add(mrg_p)
' f.Invoke(New MethodInvoker(A ddressOf f.YourMethod))
MainForm.Invoke (New MethodInvoker(A ddressOf MainForm.Contro ls.Add))
MainMarque.Visi ble = False
With mrg_p
.Top = 0
.Left = 0
.Dock = DockStyle.Fill
End With
MakeWindowAlway sTop(mrg_p.Hand le.ToInt32)
mrg_p.Show()
mrg_p.Visible = True
End Sub
Public Sub hide_bussy()
t.Abort()
End Sub
"Armin Zingler" <az*******@free net.dewrote in message
news:OT******** ******@TK2MSFTN GP06.phx.gbl...
"Jameson" <mr********@gma il.comschrieb
>Small example maybe?
I looked up some articles but I'm not seeing much that sounds like
what I am trying to do.
"Armin Zingler" <az*******@free net.dewrote in message
news:%2******* *********@TK2MS FTNGP06.phx.gbl ...
"Jameson" <mr********@gma il.comschrieb
...is this possible?
You'd better put the question in the body not in the subject line.
Answer: Yes. Call the form's invoke/begininvoke method. In the
procedure called by invoke/begininvoke, add the control.
f.Invoke(New MethodInvoker(A ddressOf f.YourMethod))
while f is the Form reference, and YourMethod is the method adding the
control. However, I'd raise a neutral event instead that is handled by the
Form and excutes the line above (replace 'f' by 'Me'). One shouldn't care
about the UI in a worker thread (IMO).
Armin