threads and delegates

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

newbie delegates question

i'm using this code:

sub empezar()
Dim del As MyDelSub
Dim del2 As MyDelSub
Dim delAll As [Delegate]
del = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
delAll = MulticastDelegate.Combine(del, del2)
delAll.DynamicInvoke(Nothing)
End Sub

and i'd like to launch 2 simultaneous delegates , How could i do it???
 
Hi,

You will have to use BeginInvoke on del1 and del2. You will not need
delAll in that scenario.
 
Patrik ,

How must i do it?

Patrik Löwendahl said:
Hi,

You will have to use BeginInvoke on del1 and del2. You will not need
delAll in that scenario.

--
Patrik Löwendahl [C# MVP]
http://www.lowendahl.net/ || http://www.cshrp.net
newbie delegates question

i'm using this code:

sub empezar()
Dim del As MyDelSub
Dim del2 As MyDelSub
Dim delAll As [Delegate]
del = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
delAll = MulticastDelegate.Combine(del, del2)
delAll.DynamicInvoke(Nothing)
End Sub

and i'd like to launch 2 simultaneous delegates , How could i do it???
 
i've proved this
Sub empezar()
Dim del1 As MyDelSub
Dim del2 As MyDelSub
Dim del3 As MyDelSub
Dim del4 As MyDelSub
Dim del5 As MyDelSub
Dim del6 As MyDelSub
Dim del7 As MyDelSub
Dim del8 As MyDelSub
Dim del9 As MyDelSub
Dim del10 As MyDelSub

Dim delAll As [Delegate]
del1 = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
del3 = New MyDelSub(AddressOf hilo3)
del4 = New MyDelSub(AddressOf hilo4)
del5 = New MyDelSub(AddressOf hilo5)
del6 = New MyDelSub(AddressOf hilo6)
del7 = New MyDelSub(AddressOf hilo7)
del8 = New MyDelSub(AddressOf hilo8)
del9 = New MyDelSub(AddressOf hilo9)
del10 = New MyDelSub(AddressOf hilo10)
BeginInvoke(del1)
BeginInvoke(del2)
BeginInvoke(del3)
BeginInvoke(del4)
BeginInvoke(del5)
BeginInvoke(del6)
BeginInvoke(del7)
BeginInvoke(del8)
BeginInvoke(del9)
BeginInvoke(del10)
end sub

but it seems only las thread del10 runs, but de textbox that shows results
only it runs with del10 first

Patrik Löwendahl said:
Hi,

You will have to use BeginInvoke on del1 and del2. You will not need
delAll in that scenario.

--
Patrik Löwendahl [C# MVP]
http://www.lowendahl.net/ || http://www.cshrp.net
newbie delegates question

i'm using this code:

sub empezar()
Dim del As MyDelSub
Dim del2 As MyDelSub
Dim delAll As [Delegate]
del = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
delAll = MulticastDelegate.Combine(del, del2)
delAll.DynamicInvoke(Nothing)
End Sub

and i'd like to launch 2 simultaneous delegates , How could i do it???
 
Sub empezar()
Dim del1 As MyDelSub
Dim del2 As MyDelSub
Dim del3 As MyDelSub
Dim del4 As MyDelSub
Dim del5 As MyDelSub
Dim del6 As MyDelSub
Dim del7 As MyDelSub
Dim del8 As MyDelSub
Dim del9 As MyDelSub
Dim del10 As MyDelSub

Dim delAll As [Delegate]
del1 = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
del3 = New MyDelSub(AddressOf hilo3)
del4 = New MyDelSub(AddressOf hilo4)
del5 = New MyDelSub(AddressOf hilo5)
del6 = New MyDelSub(AddressOf hilo6)
del7 = New MyDelSub(AddressOf hilo7)
del8 = New MyDelSub(AddressOf hilo8)
del9 = New MyDelSub(AddressOf hilo9)
del10 = New MyDelSub(AddressOf hilo10)
del1.BeginInvoke()
del2.BeginInvoke()
del3.BeginInvoke()
del4.BeginInvoke()
del5.BeginInvoke()
del6.BeginInvoke()
del7.BeginInvoke()
del8.BeginInvoke()
end sub
--
Patrik Löwendahl [C# MVP]
http://www.lowendahl.net/ || http://www.cshrp.net
Please reply only to the newsgroup.
i've proved this
Sub empezar()
Dim del1 As MyDelSub
Dim del2 As MyDelSub
Dim del3 As MyDelSub
Dim del4 As MyDelSub
Dim del5 As MyDelSub
Dim del6 As MyDelSub
Dim del7 As MyDelSub
Dim del8 As MyDelSub
Dim del9 As MyDelSub
Dim del10 As MyDelSub

Dim delAll As [Delegate]
del1 = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
del3 = New MyDelSub(AddressOf hilo3)
del4 = New MyDelSub(AddressOf hilo4)
del5 = New MyDelSub(AddressOf hilo5)
del6 = New MyDelSub(AddressOf hilo6)
del7 = New MyDelSub(AddressOf hilo7)
del8 = New MyDelSub(AddressOf hilo8)
del9 = New MyDelSub(AddressOf hilo9)
del10 = New MyDelSub(AddressOf hilo10)
BeginInvoke(del1)
BeginInvoke(del2)
BeginInvoke(del3)
BeginInvoke(del4)
BeginInvoke(del5)
BeginInvoke(del6)
BeginInvoke(del7)
BeginInvoke(del8)
BeginInvoke(del9)
BeginInvoke(del10)
end sub

but it seems only las thread del10 runs, but de textbox that shows results
only it runs with del10 first

:

Hi,

You will have to use BeginInvoke on del1 and del2. You will not need
delAll in that scenario.

--
Patrik Löwendahl [C# MVP]
http://www.lowendahl.net/ || http://www.cshrp.net
newbie delegates question

i'm using this code:

sub empezar()
Dim del As MyDelSub
Dim del2 As MyDelSub
Dim delAll As [Delegate]
del = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
delAll = MulticastDelegate.Combine(del, del2)
delAll.DynamicInvoke(Nothing)
End Sub

and i'd like to launch 2 simultaneous delegates , How could i do it???
 
i have used this and error brings to me:

Argument not specified for parameter 'DelegateCallback' of 'Public
Overridable Function BeginInvoke(DelegateCallback As System.AsyncCallback,
DelegateAsyncState As Object) As System.IAsyncResult'. C:\Documents and
Settings\axe\Mis documentos\Visual
Studio\Projects\dominios_visuales\dominios_visuales\Form1.vb 383 8


Patrik Löwendahl said:
Sub empezar()
Dim del1 As MyDelSub
Dim del2 As MyDelSub
Dim del3 As MyDelSub
Dim del4 As MyDelSub
Dim del5 As MyDelSub
Dim del6 As MyDelSub
Dim del7 As MyDelSub
Dim del8 As MyDelSub
Dim del9 As MyDelSub
Dim del10 As MyDelSub

Dim delAll As [Delegate]
del1 = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
del3 = New MyDelSub(AddressOf hilo3)
del4 = New MyDelSub(AddressOf hilo4)
del5 = New MyDelSub(AddressOf hilo5)
del6 = New MyDelSub(AddressOf hilo6)
del7 = New MyDelSub(AddressOf hilo7)
del8 = New MyDelSub(AddressOf hilo8)
del9 = New MyDelSub(AddressOf hilo9)
del10 = New MyDelSub(AddressOf hilo10)
del1.BeginInvoke()
del2.BeginInvoke()
del3.BeginInvoke()
del4.BeginInvoke()
del5.BeginInvoke()
del6.BeginInvoke()
del7.BeginInvoke()
del8.BeginInvoke()
end sub
--
Patrik Löwendahl [C# MVP]
http://www.lowendahl.net/ || http://www.cshrp.net
Please reply only to the newsgroup.
i've proved this
Sub empezar()
Dim del1 As MyDelSub
Dim del2 As MyDelSub
Dim del3 As MyDelSub
Dim del4 As MyDelSub
Dim del5 As MyDelSub
Dim del6 As MyDelSub
Dim del7 As MyDelSub
Dim del8 As MyDelSub
Dim del9 As MyDelSub
Dim del10 As MyDelSub

Dim delAll As [Delegate]
del1 = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
del3 = New MyDelSub(AddressOf hilo3)
del4 = New MyDelSub(AddressOf hilo4)
del5 = New MyDelSub(AddressOf hilo5)
del6 = New MyDelSub(AddressOf hilo6)
del7 = New MyDelSub(AddressOf hilo7)
del8 = New MyDelSub(AddressOf hilo8)
del9 = New MyDelSub(AddressOf hilo9)
del10 = New MyDelSub(AddressOf hilo10)
BeginInvoke(del1)
BeginInvoke(del2)
BeginInvoke(del3)
BeginInvoke(del4)
BeginInvoke(del5)
BeginInvoke(del6)
BeginInvoke(del7)
BeginInvoke(del8)
BeginInvoke(del9)
BeginInvoke(del10)
end sub

but it seems only las thread del10 runs, but de textbox that shows results
only it runs with del10 first

:

Hi,

You will have to use BeginInvoke on del1 and del2. You will not need
delAll in that scenario.

--
Patrik Löwendahl [C# MVP]
http://www.lowendahl.net/ || http://www.cshrp.net

axxegfx wrote:

newbie delegates question

i'm using this code:

sub empezar()
Dim del As MyDelSub
Dim del2 As MyDelSub
Dim delAll As [Delegate]
del = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
delAll = MulticastDelegate.Combine(del, del2)
delAll.DynamicInvoke(Nothing)
End Sub

and i'd like to launch 2 simultaneous delegates , How could i do it???
 
Sorry,

BeginInvoke need some extra arguments.

del1.BeginInvoke(null, null)
--
Patrik Löwendahl [C# MVP]
http://www.lowendahl.net/ || http://www.cshrp.net
Please reply only to the newsgroup.
i have used this and error brings to me:

Argument not specified for parameter 'DelegateCallback' of 'Public
Overridable Function BeginInvoke(DelegateCallback As System.AsyncCallback,
DelegateAsyncState As Object) As System.IAsyncResult'. C:\Documents and
Settings\axe\Mis documentos\Visual
Studio\Projects\dominios_visuales\dominios_visuales\Form1.vb 383 8


:

Sub empezar()
Dim del1 As MyDelSub
Dim del2 As MyDelSub
Dim del3 As MyDelSub
Dim del4 As MyDelSub
Dim del5 As MyDelSub
Dim del6 As MyDelSub
Dim del7 As MyDelSub
Dim del8 As MyDelSub
Dim del9 As MyDelSub
Dim del10 As MyDelSub

Dim delAll As [Delegate]
del1 = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
del3 = New MyDelSub(AddressOf hilo3)
del4 = New MyDelSub(AddressOf hilo4)
del5 = New MyDelSub(AddressOf hilo5)
del6 = New MyDelSub(AddressOf hilo6)
del7 = New MyDelSub(AddressOf hilo7)
del8 = New MyDelSub(AddressOf hilo8)
del9 = New MyDelSub(AddressOf hilo9)
del10 = New MyDelSub(AddressOf hilo10)
del1.BeginInvoke()
del2.BeginInvoke()
del3.BeginInvoke()
del4.BeginInvoke()
del5.BeginInvoke()
del6.BeginInvoke()
del7.BeginInvoke()
del8.BeginInvoke()
end sub
--
Patrik Löwendahl [C# MVP]
http://www.lowendahl.net/ || http://www.cshrp.net
Please reply only to the newsgroup.
i've proved this
Sub empezar()
Dim del1 As MyDelSub
Dim del2 As MyDelSub
Dim del3 As MyDelSub
Dim del4 As MyDelSub
Dim del5 As MyDelSub
Dim del6 As MyDelSub
Dim del7 As MyDelSub
Dim del8 As MyDelSub
Dim del9 As MyDelSub
Dim del10 As MyDelSub

Dim delAll As [Delegate]
del1 = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
del3 = New MyDelSub(AddressOf hilo3)
del4 = New MyDelSub(AddressOf hilo4)
del5 = New MyDelSub(AddressOf hilo5)
del6 = New MyDelSub(AddressOf hilo6)
del7 = New MyDelSub(AddressOf hilo7)
del8 = New MyDelSub(AddressOf hilo8)
del9 = New MyDelSub(AddressOf hilo9)
del10 = New MyDelSub(AddressOf hilo10)
BeginInvoke(del1)
BeginInvoke(del2)
BeginInvoke(del3)
BeginInvoke(del4)
BeginInvoke(del5)
BeginInvoke(del6)
BeginInvoke(del7)
BeginInvoke(del8)
BeginInvoke(del9)
BeginInvoke(del10)
end sub

but it seems only las thread del10 runs, but de textbox that shows results
only it runs with del10 first

:



Hi,

You will have to use BeginInvoke on del1 and del2. You will not need
delAll in that scenario.

--
Patrik Löwendahl [C# MVP]
http://www.lowendahl.net/ || http://www.cshrp.net

axxegfx wrote:


newbie delegates question

i'm using this code:

sub empezar()
Dim del As MyDelSub
Dim del2 As MyDelSub
Dim delAll As [Delegate]
del = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
delAll = MulticastDelegate.Combine(del, del2)
delAll.DynamicInvoke(Nothing)
End Sub

and i'd like to launch 2 simultaneous delegates , How could i do it???
 
OHHH my god, it's impossible

i use this:

Dim del1 As MyDelSub
Dim del2 As MyDelSub
Dim del3 As MyDelSub
Dim del4 As MyDelSub
Dim del5 As MyDelSub
Dim del6 As MyDelSub
Dim del7 As MyDelSub
Dim del8 As MyDelSub
Dim del9 As MyDelSub
Dim del10 As MyDelSub
Dim delAll As [Delegate]
del1 = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
del3 = New MyDelSub(AddressOf hilo3)
del4 = New MyDelSub(AddressOf hilo4)
del5 = New MyDelSub(AddressOf hilo5)
del6 = New MyDelSub(AddressOf hilo6)
del7 = New MyDelSub(AddressOf hilo7)
del8 = New MyDelSub(AddressOf hilo8)
del9 = New MyDelSub(AddressOf hilo9)
del10 = New MyDelSub(AddressOf hilo10)

'delAll = MulticastDelegate.Combine(del1, del2, del3, del4, del5,
del6, del7, del8, del9, del10)
'delAll.DynamicInvoke(Nothing)
del1.BeginInvoke(DBNull.Value, DBNull.Value)
del2.BeginInvoke(DBNull.Value, DBNull.Value)
a new error brings:

Error 1 Value of type 'System.DBNull' cannot be converted to
'System.AsyncCallback'.C:\Documents and Settings\axe\Mis documentos\Visual
Studio\Projects\dominios_visuales\dominios_visuales\Form1.vb 387 25

and it runs first delegate and then the other when firts has finished.

i'm trying to change de code to this:
function hilo(ByVal dominio As String, ByVal numero As String, ByRef
dirsAnalizados As Integer) As ArrayList
me.textbox1.text="HELLO"
end function
Delegate Function hiloDelegate(ByVal dominio As String, ByVal numero As
String, ByRef dirsAnalizados As Integer) As ArrayList
Private Sub iniciar_hilos()
Dim ar(1) As IAsyncResult
Dim a As Integer = 0
Dim domino As String = ".com"
Dim hiloDelegate As New hiloDelegate(AddressOf hilo)
ar(0) = hiloDelegate.BeginInvoke("", "", a, Nothing, Nothing)
'ar(1) = hiloDelegate.BeginInvoke("", "", a, Nothing, Nothing)
Dim waitHandles() As WaitHandle = {ar(0).AsyncWaitHandle}
Do Until WaitHandle.WaitAll(waitHandles, 500, False)
Loop
End Sub

but i get:

Illegal cross-thread operation: Control 'TextBox1' accessed from a thread
other than the thread it was created on.Stack trace where the illegal
operation occurred was:
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.get_WindowText()
at System.Windows.Forms.TextBoxBase.get_WindowText()
at System.Windows.Forms.Control.get_Text()
at System.Windows.Forms.TextBoxBase.set_Text(String)
at System.Windows.Forms.TextBox.set_Text(String)
at WindowsApplication1.Form1.hilo(String, String, Int32&)
at
System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr, Object[], Object, Int32, Boolean, Object[]&)
at
System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle, Object[], Object, Int32, Boolean, Object[]&)
at
System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage, IMessageSink)
at
System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object)
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object)
at System.Threading.ExecutionContext.Run(ExecutionContext, ContextCallback,
Object, StackCrawlMark&)
at System.Threa..."

Patrik Löwendahl said:
Sorry,

BeginInvoke need some extra arguments.

del1.BeginInvoke(null, null)
--
Patrik Löwendahl [C# MVP]
http://www.lowendahl.net/ || http://www.cshrp.net
Please reply only to the newsgroup.
i have used this and error brings to me:

Argument not specified for parameter 'DelegateCallback' of 'Public
Overridable Function BeginInvoke(DelegateCallback As System.AsyncCallback,
DelegateAsyncState As Object) As System.IAsyncResult'. C:\Documents and
Settings\axe\Mis documentos\Visual
Studio\Projects\dominios_visuales\dominios_visuales\Form1.vb 383 8


:

Sub empezar()
Dim del1 As MyDelSub
Dim del2 As MyDelSub
Dim del3 As MyDelSub
Dim del4 As MyDelSub
Dim del5 As MyDelSub
Dim del6 As MyDelSub
Dim del7 As MyDelSub
Dim del8 As MyDelSub
Dim del9 As MyDelSub
Dim del10 As MyDelSub

Dim delAll As [Delegate]
del1 = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
del3 = New MyDelSub(AddressOf hilo3)
del4 = New MyDelSub(AddressOf hilo4)
del5 = New MyDelSub(AddressOf hilo5)
del6 = New MyDelSub(AddressOf hilo6)
del7 = New MyDelSub(AddressOf hilo7)
del8 = New MyDelSub(AddressOf hilo8)
del9 = New MyDelSub(AddressOf hilo9)
del10 = New MyDelSub(AddressOf hilo10)
del1.BeginInvoke()
del2.BeginInvoke()
del3.BeginInvoke()
del4.BeginInvoke()
del5.BeginInvoke()
del6.BeginInvoke()
del7.BeginInvoke()
del8.BeginInvoke()
end sub
--
Patrik Löwendahl [C# MVP]
http://www.lowendahl.net/ || http://www.cshrp.net
Please reply only to the newsgroup.

axxegfx wrote:

i've proved this
Sub empezar()
Dim del1 As MyDelSub
Dim del2 As MyDelSub
Dim del3 As MyDelSub
Dim del4 As MyDelSub
Dim del5 As MyDelSub
Dim del6 As MyDelSub
Dim del7 As MyDelSub
Dim del8 As MyDelSub
Dim del9 As MyDelSub
Dim del10 As MyDelSub

Dim delAll As [Delegate]
del1 = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
del3 = New MyDelSub(AddressOf hilo3)
del4 = New MyDelSub(AddressOf hilo4)
del5 = New MyDelSub(AddressOf hilo5)
del6 = New MyDelSub(AddressOf hilo6)
del7 = New MyDelSub(AddressOf hilo7)
del8 = New MyDelSub(AddressOf hilo8)
del9 = New MyDelSub(AddressOf hilo9)
del10 = New MyDelSub(AddressOf hilo10)
BeginInvoke(del1)
BeginInvoke(del2)
BeginInvoke(del3)
BeginInvoke(del4)
BeginInvoke(del5)
BeginInvoke(del6)
BeginInvoke(del7)
BeginInvoke(del8)
BeginInvoke(del9)
BeginInvoke(del10)
end sub

but it seems only las thread del10 runs, but de textbox that shows results
only it runs with del10 first

:



Hi,

You will have to use BeginInvoke on del1 and del2. You will not need
delAll in that scenario.

--
Patrik Löwendahl [C# MVP]
http://www.lowendahl.net/ || http://www.cshrp.net

axxegfx wrote:


newbie delegates question

i'm using this code:

sub empezar()
Dim del As MyDelSub
Dim del2 As MyDelSub
Dim delAll As [Delegate]
del = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
delAll = MulticastDelegate.Combine(del, del2)
delAll.DynamicInvoke(Nothing)
End Sub

and i'd like to launch 2 simultaneous delegates , How could i do it???
 
Patrik i see the big light
could you help me with this code??

Imports System.Threading
Public Class Form1

Function hilo(ByVal dominio As String, ByVal numero As Integer, ByRef
resultado As String) As String

End Function
Delegate Function hiloDelegate(ByVal dominio As String, ByVal numero As
Integer, ByRef resultado As String) As String

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim ar(1) As IAsyncResult
Dim a As Integer = 0
Dim dominio(1), resultado As String
dominio(1) = "terra.com"
Dim hiloDelegate As New hiloDelegate(AddressOf hilo)
ar(0) = hiloDelegate.BeginInvoke(dominio(1), "", resultado)
Me.TextBox1.Text = "HOLA"
Dim waitHandles() As WaitHandle = {ar(0).AsyncWaitHandle}
Do Until WaitHandle.WaitAll(waitHandles, 500, False)
Loop
End Sub

End Class

sure it's so easy but i'm a newbie and young programmer

it brings to me:
Error 1 Argument not specified for parameter 'DelegateCallback' of 'Public
Overridable Function BeginInvoke(dominio As String, numero As Integer, ByRef
resultado As String, DelegateCallback As System.AsyncCallback,
DelegateAsyncState As Object) As System.IAsyncResult'. C:\Documents and
Settings\axe\Configuración local\Datos de programa\Temporary
Projects\WindowsApplication1\Form1.vb 15 16


Patrik Löwendahl said:
Sorry,

BeginInvoke need some extra arguments.

del1.BeginInvoke(null, null)
--
Patrik Löwendahl [C# MVP]
http://www.lowendahl.net/ || http://www.cshrp.net
Please reply only to the newsgroup.
i have used this and error brings to me:

Argument not specified for parameter 'DelegateCallback' of 'Public
Overridable Function BeginInvoke(DelegateCallback As System.AsyncCallback,
DelegateAsyncState As Object) As System.IAsyncResult'. C:\Documents and
Settings\axe\Mis documentos\Visual
Studio\Projects\dominios_visuales\dominios_visuales\Form1.vb 383 8


:

Sub empezar()
Dim del1 As MyDelSub
Dim del2 As MyDelSub
Dim del3 As MyDelSub
Dim del4 As MyDelSub
Dim del5 As MyDelSub
Dim del6 As MyDelSub
Dim del7 As MyDelSub
Dim del8 As MyDelSub
Dim del9 As MyDelSub
Dim del10 As MyDelSub

Dim delAll As [Delegate]
del1 = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
del3 = New MyDelSub(AddressOf hilo3)
del4 = New MyDelSub(AddressOf hilo4)
del5 = New MyDelSub(AddressOf hilo5)
del6 = New MyDelSub(AddressOf hilo6)
del7 = New MyDelSub(AddressOf hilo7)
del8 = New MyDelSub(AddressOf hilo8)
del9 = New MyDelSub(AddressOf hilo9)
del10 = New MyDelSub(AddressOf hilo10)
del1.BeginInvoke()
del2.BeginInvoke()
del3.BeginInvoke()
del4.BeginInvoke()
del5.BeginInvoke()
del6.BeginInvoke()
del7.BeginInvoke()
del8.BeginInvoke()
end sub
--
Patrik Löwendahl [C# MVP]
http://www.lowendahl.net/ || http://www.cshrp.net
Please reply only to the newsgroup.

axxegfx wrote:

i've proved this
Sub empezar()
Dim del1 As MyDelSub
Dim del2 As MyDelSub
Dim del3 As MyDelSub
Dim del4 As MyDelSub
Dim del5 As MyDelSub
Dim del6 As MyDelSub
Dim del7 As MyDelSub
Dim del8 As MyDelSub
Dim del9 As MyDelSub
Dim del10 As MyDelSub

Dim delAll As [Delegate]
del1 = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
del3 = New MyDelSub(AddressOf hilo3)
del4 = New MyDelSub(AddressOf hilo4)
del5 = New MyDelSub(AddressOf hilo5)
del6 = New MyDelSub(AddressOf hilo6)
del7 = New MyDelSub(AddressOf hilo7)
del8 = New MyDelSub(AddressOf hilo8)
del9 = New MyDelSub(AddressOf hilo9)
del10 = New MyDelSub(AddressOf hilo10)
BeginInvoke(del1)
BeginInvoke(del2)
BeginInvoke(del3)
BeginInvoke(del4)
BeginInvoke(del5)
BeginInvoke(del6)
BeginInvoke(del7)
BeginInvoke(del8)
BeginInvoke(del9)
BeginInvoke(del10)
end sub

but it seems only las thread del10 runs, but de textbox that shows results
only it runs with del10 first

:



Hi,

You will have to use BeginInvoke on del1 and del2. You will not need
delAll in that scenario.

--
Patrik Löwendahl [C# MVP]
http://www.lowendahl.net/ || http://www.cshrp.net

axxegfx wrote:


newbie delegates question

i'm using this code:

sub empezar()
Dim del As MyDelSub
Dim del2 As MyDelSub
Dim delAll As [Delegate]
del = New MyDelSub(AddressOf hilo1)
del2 = New MyDelSub(AddressOf hilo2)
delAll = MulticastDelegate.Combine(del, del2)
delAll.DynamicInvoke(Nothing)
End Sub

and i'd like to launch 2 simultaneous delegates , How could i do it???
 
Back
Top