我创建了一个列表,threads以实现Multi Threading全部接受一个返回值的函数。以下是我尝试过的代码:
创建线程
Dim txt as String
For i As Integer = 0 To 15
txt = ""
txt = UCase(array.Item(i))
Dim tempThread As Threading.Thread = New Threading.Thread(AddressOf threadRead)
tempThread .Start(txt) ' start thread by passing value to it
Threads.Add(tempThread ) 'Add thread to the list
'Here i want to add the return value from the thread to RichTextbox
'as follows
RichTextBox1.Text = RichTextBox1.Text & vbNewLine & tempThread.ReturnValue
Next
Run Code Online (Sandbox Code Playgroud)
线程处理的功能
Public Function threadRead(ByVal txtInput As String) …Run Code Online (Sandbox Code Playgroud) namespace Tales_Of_Myroth
{
public class TalesOfMyroth
{
static void Main(string[] args)
{
TalesOfMyroth(); //here is my error
}
private Jogador _jogador;
public TalesOfMyroth()
{
_jogador = new Jogador();
_jogador.VidaAtual = 50;
_jogador.VidaMaxima = 50;
_jogador.Ouro = 0;
Console.WriteLine("Vida: " + _jogador.VidaAtual);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我本来想为我刚刚开始的大学制作一个简单的文字游戏......有人可以帮助我吗?(代码中的某些内容是用葡萄牙语编写的)
无论"Try.... Catch"和" On Error GoTo"是的异常处理机制,VB.NET,然后是他们之间有什么区别呢?
以下是什么原因?
一个块将允许多个try..catch或多个On Error GoTo但not both允许在同一个块中.
对于以下代码:
Private Sub check_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles check.Click
On Error GoTo l1
On Error GoTo l2
rt.LoadFile("e:\new\me.txt")
l1:TextBox1.Text = "Not found"
l2:TextBox1.Text = "Not found"
End Sub
Run Code Online (Sandbox Code Playgroud)
如果找不到路径,为什么l2在执行之前l1执行?