471,339 Members | 1,284 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,339 software developers and data experts.

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 2028
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Joey Powell | last post: by
22 posts views Thread by Jeff Louie | last post: by
12 posts views Thread by Grant | last post: by
11 posts views Thread by Peter Kirk | last post: by
7 posts views Thread by Waleed AlRashoud | last post: by
14 posts views Thread by Lior Amar | last post: by
15 posts views Thread by Bryce K. Nielsen | last post: by
14 posts views Thread by Gotch | last post: by

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.