English 中文(简体)
VB. NET 相当于时间范围。
原标题:VB.NET equivalent of Timeout.bas Module from VB6

我期待着万国邮联。 * 基本文件一用于视觉基础6。 档案被称作是时事,是我有史以来最大的模块。 我想开始使用VB。 NET最后是,这一单一档案被搁置回头。 努力使用。 如果没有这个网络,我就感到困惑。 任何人都可以使这一法典发挥作用。 供我使用的网络?

这只是一条两条:

Attribute VB_Name = "Module1"
Sub timeout(duration)
starttime = Timer
Do While Timer - starttime < duration
DoEvents
Loop
End Sub

基本上,你补充说这一时间。 载有该法典的基本文件,你可以这样做:

Text1.text = "hello"
timeout .5
Text1.text "World!"

它非常麻烦。 任何人都可以在VB重新使用。 供我使用的网络! 感谢!

问题回答

这对不停的忙.徒徒劳无益。

你可以做字面翻译到VB。 净值为两行:

System.Threading.Thread.Current.Sleep(1000)
Application.DoEvents

这将睡在第二位,然后处理每台电传。

然而,你应真心 ask问,为什么你需要等待一定时间? 你们在等待什么,以及你能否以不同的方式等待? 如果主线正在等待背景工作者的结束,那么你就能够让主线继续走下去,把信息循环正常处理,而背景工人只能用发送人通知。

Sub timeout(ByVal duration As Double)
    Dim starttime = DateTime.Now
    Do While (DateTime.Now  - starttime).TotalSeconds < duration
        My.Application.DoEvents()
    Loop
End Sub

在你使用时,确定可伪造财产的形式。

你可以做到:

System.Threading.Thread.Sleep(5000);

令人沮丧的是,有些事情被阻止。 网上和将锁定贵方。

审判

Sub timeout(seconds)
   Dim endtime = DateTime.Now.AddSeconds(seconds)
   Do While DateTime.Now < endtime
     threading.thread.sleep(100)
     application.doevents
   Loop
End Sub




相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签