Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 它可以使计时器像VisualBasic那样使用不到的API_Vb.net_Asynchronous_Timer_Chat_Skype4com - Fatal编程技术网

Vb.net 它可以使计时器像VisualBasic那样使用不到的API

Vb.net 它可以使计时器像VisualBasic那样使用不到的API,vb.net,asynchronous,timer,chat,skype4com,Vb.net,Asynchronous,Timer,Chat,Skype4com,我一直在尝试一些事情来达到预期的效果,但是没有很好的效果,因为我对这门语言不是很了解。 我希望“函数”c.SendMessagese发送延迟X秒。在我继续调查的过程中,我希望你能帮助我。谢谢你的帮助 示例 send delay 5sec c.SendMessage("Esto no es un comando1") send delay 8sec c.SendMessage("Esto no es un comando2") send delay 11sec c.SendMessage("Est

我一直在尝试一些事情来达到预期的效果,但是没有很好的效果,因为我对这门语言不是很了解。 我希望“函数”c.SendMessagese发送延迟X秒。在我继续调查的过程中,我希望你能帮助我。谢谢你的帮助

示例

send delay 5sec c.SendMessage("Esto no es un comando1")
send delay 8sec c.SendMessage("Esto no es un comando2")
send delay 11sec c.SendMessage("Esto no es un comando3")
send delay 14sec c.SendMessage("Esto no es un comando4")
    Private Sub oSkype_MessageStatus(pMessage As ChatMessage, Status As TChatMessageStatus) Handles oSkype.MessageStatus
    If Status = TChatMessageStatus.cmsReceived Or Status = TChatMessageStatus.cmsSent Then
        Dim msg As String = pMessage.Body
        Dim c As Chat = pMessage.Chat

        If msg.StartsWith(Trigger) Then
            LstBox.Items.Add(DateTime.Now.ToLongTimeString() + ":" + "command " + "'" + msg + "'" + "form " + pMessage.Sender.Handle)
            msg = msg.Remove(0, 1).ToLower
            c.SendMessage("Esto no es un comando1")
            c.SendMessage("Esto no es un comando2")
            c.SendMessage("Esto no es un comando3")
            c.SendMessage("Esto no es un comando4")
        End If
    End If
End Sub
我希望我能理解

我的代码

send delay 5sec c.SendMessage("Esto no es un comando1")
send delay 8sec c.SendMessage("Esto no es un comando2")
send delay 11sec c.SendMessage("Esto no es un comando3")
send delay 14sec c.SendMessage("Esto no es un comando4")
    Private Sub oSkype_MessageStatus(pMessage As ChatMessage, Status As TChatMessageStatus) Handles oSkype.MessageStatus
    If Status = TChatMessageStatus.cmsReceived Or Status = TChatMessageStatus.cmsSent Then
        Dim msg As String = pMessage.Body
        Dim c As Chat = pMessage.Chat

        If msg.StartsWith(Trigger) Then
            LstBox.Items.Add(DateTime.Now.ToLongTimeString() + ":" + "command " + "'" + msg + "'" + "form " + pMessage.Sender.Handle)
            msg = msg.Remove(0, 1).ToLower
            c.SendMessage("Esto no es un comando1")
            c.SendMessage("Esto no es un comando2")
            c.SendMessage("Esto no es un comando3")
            c.SendMessage("Esto no es un comando4")
        End If
    End If
End Sub

您可以使用方法将当前线程的执行暂停“X”个时间

每个订单之间3秒钟内休眠的示例:

Imports System.Threading

Console.WriteLine("1")
Thread.Sleep(TimeSpan.FromSeconds(3))

Console.WriteLine("2")
Thread.Sleep(TimeSpan.FromSeconds(3))

Console.WriteLine("3")
Thread.Sleep(TimeSpan.FromSeconds(3))
如果您使用异步方法来避免冻结UI线程,效果会更好:

Imports System.Threading
Imports System.Threading.Tasks

Dim t As New task(
    Sub()
        Console.WriteLine("1")
        Thread.Sleep(TimeSpan.FromSeconds(3))

        Console.WriteLine("2")
        Thread.Sleep(TimeSpan.FromSeconds(3))

        Console.WriteLine("3")
        Thread.Sleep(TimeSpan.FromSeconds(3))
    End Sub)

t.Start()


正如与问题无关的建议一样,请避免使用
+
运算符连接字符串,正如我解释的

我们也希望您理解。我们没有。