大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
1、我有一个function,如下:
仙游ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:028-86922220(备注:SSL证书合作)期待与您的合作!
function b()
'...
return "abc"
end function
2、调用时,这样子用:
Response.write(b());
3、运行结果:
abc
Public Class Form1
Public Class SquareClass '把多线程调用的函数封装到类中,通过类事件返回
Public Value As Double
Public Square As Double
Public Event ThreadComplete(ByVal Square As Double)
Public Sub CalcSquare()
Square = Value * Value
RaiseEvent ThreadComplete(Square)
End Sub
End Class
Dim WithEvents oSquare As SquareClass
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click '多线程返回值测试,当线程运行完成激发事件
oSquare = New SquareClass()
Dim t As New Threading.Thread(AddressOf oSquare.CalcSquare)
oSquare.Value = 30
t.Start()
End Sub
Sub SquareEventHandler(ByVal Square As Double) Handles oSquare.ThreadComplete '响应事件函数
MsgBox("The square is " Square)
End Sub
End Class
.Net的所有类型都是从System.Object派生而来的,所以将函数直接定义成
Function Prior() As Object 即可
不过在返回之后,调用此函数的代码要注意验证返回值的有效性
Thread不会返回值的。你应该创建委托的,使用委托的异步方法
Dim funcInt32 As Func(Of String, Integer) = AddressOf GetList
Dim s As IAsyncResult = funcInt32.BeginInvoke("(参数)", Nothing, Nothing)
’在要获得结果的地方调用EndInvoke方法结束异步调用并获得结果。
Dim result As Int32 = funcInt32.EndInvoke(s)