how to handle exception?

master
この中二病に爆焔を! 5 years ago
parent b7332f5a82
commit cb378c5eef

@ -74,37 +74,44 @@ Public Class SlaveTask
Call Console.WriteLine($"[{host.GetHashCode.ToHexString}] port:{host.HostPort}")
Call Thread.Sleep(100)
Dim resultStream As MemoryStream
' Dim resultStream As MemoryStream
Dim commandlineArgvs As String = builder(processor, host.HostPort)
'If Not debugPort Is Nothing Then
' Pause()
' Console.WriteLine(commandlineArgvs)
' Pause()
'End If
#If netcore5 = 0 Then
resultStream = CommandLine.CallDotNetCorePipeline(processor, commandlineArgvs)
#Else
resultStream = CommandLine.CallDotNetCorePipeline(processor, commandlineArgvs)
Call CommandLine.Call(processor, commandlineArgvs, dotnet:=True)
#End If
Call host.Stop()
' Call Console.WriteLine(If(result Is Nothing, "null", result.ToString))
Call Console.WriteLine($"[{host.GetHashCode.ToHexString}] thread exit...")
result = decomposingStdoutput(resultStream, resultType, host.GetHashCode)
resultStream.Close()
resultStream.Dispose()
' result = decomposingStdoutput(resultStream, resultType, host.GetHashCode)
' resultStream.Close()
' resultStream.Dispose()
Return result
End Function
Private Function decomposingStdoutput(buffer As MemoryStream, type As Type, host As Integer) As Object
Using reader As New StreamReader(buffer)
Do While reader.ReadLine <> TaskBuilder.streamDelimiter
Dim str As Value(Of String) = ""
Do While (str = reader.ReadLine) <> TaskBuilder.streamDelimiter
' Call Console.WriteLine($"[{host.ToHexString}] {str.Value}")
Loop
Dim dataSize As Integer = Integer.Parse(reader.ReadLine)
Dim chunkBuffer As Byte() = New Byte(dataSize - 1) {}
Call Console.WriteLine($"[{host.ToHexString}] chunksize: {dataSize}/{buffer.Length}")
buffer.Seek(buffer.Length - dataSize, SeekOrigin.Begin)
buffer.Read(chunkBuffer, Scan0, chunkBuffer.Length)

@ -20,10 +20,6 @@ Public Class TaskBuilder : Implements ITaskDriver
masterPort = port
End Sub
Shared Sub New()
Console.Out.NewLine = vbLf
End Sub
Public Function Run() As Integer Implements ITaskDriver.Run
Dim task As IDelegate = GetMethod()
Dim api As MethodInfo = task.GetMethod
@ -34,6 +30,9 @@ Public Class TaskBuilder : Implements ITaskDriver
args.Add(GetArgumentValue(i))
Next
Call Console.WriteLine("run task:")
Call Console.WriteLine(task.GetJson(indent:=False, simpleDict:=True))
Dim params As ParameterInfo() = api.GetParameters
For i As Integer = n To params.Length - 1
@ -46,8 +45,9 @@ Public Class TaskBuilder : Implements ITaskDriver
' send debug message
Call New TcpRequest(masterPort).SendMessage(New RequestStream(IPCSocket.Protocol, Protocols.PostStart))
' Call PostFinished(api.Invoke(Nothing, args.ToArray))
Call PostStdOut(api.Invoke(Nothing, args.ToArray))
Call PostFinished(api.Invoke(Nothing, args.ToArray))
' Call PostStdOut(api.Invoke(Nothing, args.ToArray))
Call Console.WriteLine("job done!")
Return 0
End Function
@ -119,6 +119,7 @@ Public Class TaskBuilder : Implements ITaskDriver
Dim buf As Stream = BSONFormat.SafeGetBuffer(element)
Dim request As New RequestStream(IPCSocket.Protocol, Protocols.PostResult, New StreamPipe(buf).Read)
Call Console.WriteLine($"post result: {type.GetObjectJson(result, indent:=False)}")
Call New TcpRequest(masterPort).SendMessage(request)
End Sub
End Class

Loading…
Cancel
Save