473,471 Members | 2,017 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

threads and delegates

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???

Jul 21 '05 #1
8 2169
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???

Jul 21 '05 #2
Patrik ,

How must i do it?

"Patrik Löwendahl [C# MVP]" wrote:
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???

Jul 21 '05 #3
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 [C# MVP]" wrote:
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???

Jul 21 '05 #4
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

"Patrik Löwendahl [C# MVP]" wrote:

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???

Jul 21 '05 #5
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_visuale s\Form1.vb 383 8
"Patrik Löwendahl [C# MVP]" wrote:
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

"Patrik Löwendahl [C# MVP]" wrote:

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???

Jul 21 '05 #6
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.

axxegfx wrote:
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_visuale s\Form1.vb 383 8
"Patrik Löwendahl [C# MVP]" wrote:

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

"Patrik Löwendahl [C# MVP]" wrote:

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???
>

Jul 21 '05 #7
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_visuale s\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.AgileAsyncWorkerIt em.ThreadPoolCallBack(Object)
at System.Threading._ThreadPoolWaitCallback.WaitCallb ack_Context(Object)
at System.Threading.ExecutionContext.Run(ExecutionCon text, ContextCallback,
Object, StackCrawlMark&)
at System.Threa..."

"Patrik Löwendahl [C# MVP]" wrote:
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.

axxegfx wrote:
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_visuale s\Form1.vb 383 8
"Patrik Löwendahl [C# MVP]" wrote:

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

"Patrik Löwendahl [C# MVP]" wrote:

>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???
>>
>

Jul 21 '05 #8
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 [C# MVP]" wrote:
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.

axxegfx wrote:
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_visuale s\Form1.vb 383 8
"Patrik Löwendahl [C# MVP]" wrote:

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

"Patrik Löwendahl [C# MVP]" wrote:

>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???
>>
>

Jul 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Joey Powell | last post by:
Re: Original post = Windows forms - how do I get them to render/update properly? from August 22. Okay I am making some progress with being able to use delegates to run my shelled processes on...
22
by: Jeff Louie | last post by:
Well I wonder if my old brain can handle threading. Dose this code look reasonable. Regards, Jeff using System; using System.Diagnostics; using System.IO; using System.Threading;
12
by: Grant | last post by:
I am having great difficulty understanding this and any code samples I find online are kilometres long and complicated to understand...Please could someone give me a simple exampe of how to get a...
13
by: orekin | last post by:
Hi There I have been programming C# for a couple of months and am trying to master Threading. I understand that ThreadPool uses background threads (see code example in MSDN page titled...
11
by: Peter Kirk | last post by:
Hi there I am looking at using a thread-pool, for example one written by Jon Skeet (http://www.yoda.arachsys.com/csharp/miscutil/). Can anyone tell me if this pool provides the possibility to...
7
by: Waleed AlRashoud | last post by:
Hi All, I hvae worker class to manage the application inside worker : worker creates (n) number of threads to do IO operations. The Problem Is: to handle all threads : , , I have to...
14
by: Lior Amar | last post by:
Quick question about threads and delegates. I have the following scenario Thread A (CLASSA) spawns Thread B (CLASSB) and passes it a DelegateA to a callback Thread B Invokes a DelegateB...
15
by: Bryce K. Nielsen | last post by:
I have an object that starts a thread to do a "process". One of the steps inside this thread launches 12 other threads via a Delegate.BeginInvoke to process. After these 12 threads are launched,...
6
by: Jon Davis | last post by:
I've used delegates fairly heavily for several years in C# for event handling and for starting threads. Does anyone have any real-world scenarios where delegates were both extremely useful and...
14
by: Gotch | last post by:
Hi all, I've recently digged into C# and the whole .Net stuff. Particularly I found the idea of adding Events and Delegates to the C# language very interesting and I'm trying to use them in...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.