小编Suj*_*uji的帖子

具有返回值的多线程:vb.net

我创建了一个列表,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)

vb.net multithreading

2
推荐指数
1
解决办法
6900
查看次数

不可调用成员“TalesOfMyroth()”不能像方法一样使用

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)

我本来想为我刚刚开始的大学制作一个简单的文字游戏......有人可以帮助我吗?(代码中的某些内容是用葡萄牙语编写的)

c#

1
推荐指数
1
解决办法
7891
查看次数

使用"On Error GoTo"时出现意外的控制流程,将其与"Try .... Catch"进行比较

无论"Try.... Catch"和" On Error GoTo"是的异常处理机制,VB.NET,然后是他们之间有什么区别呢?

以下是什么原因?

  1. 一个块将允许多个try..catch或多个On Error GoTonot both允许在同一个块中.

  2. 对于以下代码:

    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执行?

vb.net try-catch

0
推荐指数
1
解决办法
131
查看次数

标签 统计

vb.net ×2

c# ×1

multithreading ×1

try-catch ×1