Passing a Sun address

  • Thread starter Thread starter **Developer**
  • Start date Start date
D

**Developer**

Now I do

SyatemSub(AddressOf Somesub)


I want to define a sub as follows


Sub2(???)
SystemSub(???)
End Sub

And call it thus:
Sub2 (Address of SomeSub)

Can I do that?
 
**Developer**
Do you mean you want to do something like:

' Define what some sub should look like
Public Delegate Sub ASub(ByVal value As Integer)

Public Sub Main()
' pass the "address" of SomeSub
Sub2(AddressOf SomeSub)
End Sub

Public Sub Sub2(ByVal asub As ASub)
' we already have the "Address" so just pass it
SystemSub(asub)
End Sub

Public Sub SystemSub(ByVal asub As ASub)
asub.Invoke(10)

' Invoke is optional, so you can also use:
asub(10)

End Sub

Public Sub SomeSub(ByVal value As Integer)
' Do something exciting with value.
End Sub


--
Hope this helps
Jay [MVP - Outlook]
T.S. Bradley - http://www.tsbradley.net


| Now I do
|
| SyatemSub(AddressOf Somesub)
|
|
| I want to define a sub as follows
|
|
| Sub2(???)
| SystemSub(???)
| End Sub
|
| And call it thus:
| Sub2 (Address of SomeSub)
|
| Can I do that?
|
|
 
Yes

It took a while because the SystenSub I had in mind was
Dim t As New Thread(?)

Now I know your example applies since there is a Delegate (ThreadStart) that
I can use.

Thanks



Public Shared Function MakeAbortThread(ByVal threadCode As ThreadStart...)
As Thread

Dim t As New Thread(threadCode)

t.Start()

-snip-

Return t

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top