473,320 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 2161
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.