我有一个启动 java JAR 文件并在运行时获取输出的程序;(来自 PowerBot.org 的 RSBot)一切正常,但我的 ListView 没有从“OutputDataReceived”事件中添加文本,但我可以在 MessageBox.Show() 中显示它;或 Debug.WriteLine();
我的 ListView 已添加到主题类中,但唯一修改的东西不是所有者绘制的。
Class GhostListView
Inherits ListView
Sub New()
Me.BackColor = Color.FromArgb(255, 21, 21, 21)
Me.BorderStyle = BorderStyle.FixedSingle
Me.ForeColor = Color.GhostWhite
Me.View = Windows.Forms.View.Details
Me.FullRowSelect = True
End Sub
End Class
所以没有任何修改会阻止以下内容添加到我的 ListView
Shared Sub RSBotProc_Output(sender As Object, e As DataReceivedEventArgs) Handles RSBotProcess.OutputDataReceived
'Sub is shared because the Process is declared publicly as shared
'Public Shared WithEvents RSBotProcess as Process = Nothing
Functions.AddBotOutput(e)
Functions.Log("Output Svc", "Received Output from Bot: " & e.Data)
Debug.WriteLine("Recvd: " & e.Data)
End Sub
函数类(如上所用)
Public Class Functions
Public Shared Sub Log(supplier As String, msg As String)
Dim s(2) As String
s(0) = DateTime.Now.ToString("HH:mm:ss-fff")
s(1) = supplier
s(2) = msg
frmLog.GhostListView1.Items.Add(New ListViewItem(s))
End Sub
Public Shared Sub AddBotOutput(Args As DataReceivedEventArgs)
Dim s(1) As String
s(0) = DateTime.Now.ToString("HH:mm:ss-fff")
s(1) = Args.Data
frmBotOutput.GhostListView1.Items.Add(New ListViewItem(s))
End Sub
End Class
调试中的输出
Recvd: [INFO] Optimising your experience
Recvd: [INFO] Starting bot
Recvd: [INFO] Loading game
Recvd: [INFO] Unpacking client (7dea8f)
Recvd: [INFO] Starting game
但是,我的 ListView 是空白的,并且项目数是 0...我在这里有点迷路,我感觉问题正盯着我看,但我一直在努力解决这个 bug 大约 20 分钟和我可能只是略过这个问题......我似乎时不时地这样做,但这次即使是 Rubber Ducky 调试也没有帮助我。另外,如果需要,我可以上传整个项目,如果他们愿意,可以让别人看一看。
编辑
为了确保从 Functions 类调用我的 log/addtobot,我添加了一个调试,输出从该函数发送到函数输出的内容:
Functions#AddBotOutput() - Attempting to add '[INFO] Optimising your experience'
Functions#Log() - Attempting to log '[Output Svc] - Received Output from Bot: [INFO] Optimising your experience'
Recvd: [INFO] Optimising your experience
Functions#AddBotOutput() - Attempting to add '[INFO] Starting bot'
Functions#Log() - Attempting to log '[Output Svc] - Received Output from Bot: [INFO] Starting bot'
Recvd: [INFO] Starting bot
Functions#AddBotOutput() - Attempting to add '[INFO] Loading game'
Functions#Log() - Attempting to log '[Output Svc] - Received Output from Bot: [INFO] Loading game'
Recvd: [INFO] Loading game