暂停这里需要的流程吗? [英] Is pausing of the process needed here?

查看:78
本文介绍了暂停这里需要的流程吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:


Dim sw As StreamWriter = File.CreateText(Application.StartupPath

&" \ maymeversion.bat" )


sw.WriteLine(lblMameExePath.Text&" -help>"""&

Application.StartupPath&" ; \ maymeversion.txt""")


sw.Close()


Dim p As New System.Diagnostics.ProcessStartInfo


p.WindowStyle = ProcessWindowStyle.Hidden


p.FileName = Application.StartupPath& " \ maymeversion.bat"


p.UseShellExecute = True


System.Diagnostics.Process.Start(p)


如果File.Exists(Application.StartupPath&" \mameversion.txt")

那么


昏暗sr As StreamReader = New

StreamReader(Application.StartupPath&" \mameversion.txt")


strLine = sr.ReadLine()


sr.Close()


lblMameVersion.Text = Mid(strLine,11,4)


frm1.dblMameVer =

System.Convert.ToDouble(lblMameVersion.Text)

lblMameVersion.Refresh()


结束如果


发生的事情是我正在创建批处理文件,然后执行

批处理文件来创建文本文件。然后我查看文本文件内部以获得

程序的版本号。如果我快速执行代码,则版本

编号永远不会写入标签控件。如果我在

调试器中单步执行它,它可以正常工作。当我尝试将其写入标签控件时,我认为该版本的运行时速度尚未找到
。我能说得对吗

在这里?如果是这样,我如何在代码中暂时停顿?


谢谢,

John

Here is my code:

Dim sw As StreamWriter = File.CreateText(Application.StartupPath
& "\mameversion.bat")

sw.WriteLine(lblMameExePath.Text & " -help >""" &
Application.StartupPath & "\mameversion.txt""")

sw.Close()

Dim p As New System.Diagnostics.ProcessStartInfo

p.WindowStyle = ProcessWindowStyle.Hidden

p.FileName = Application.StartupPath & "\mameversion.bat"

p.UseShellExecute = True

System.Diagnostics.Process.Start(p)

If File.Exists(Application.StartupPath & "\mameversion.txt")
Then

Dim sr As StreamReader = New
StreamReader(Application.StartupPath & "\mameversion.txt")

strLine = sr.ReadLine()

sr.Close()

lblMameVersion.Text = Mid(strLine, 11, 4)

frm1.dblMameVer =
System.Convert.ToDouble(lblMameVersion.Text)

lblMameVersion.Refresh()

End If

What is happening is that I am creating the batch file, then executing the
batch file to create the text file. I then look inside the text file to get
a version number of the program. If I execute the code fast the version
number never gets written into the label control. If I step through it in
the debugger, it works fine. I think a run-time speed the version is yet to
be found when I try to write it to the label control. Could I be correct
here? If so, how do I put a momentary pause in the code?

Thanks,
John

推荐答案

更多......此代码在按钮单击事件上执行。如果在执行

之后,我再次执行它,标签控件正确填充。


谢谢,

John


" jcrouse" < ME>在消息中写道

新闻:Od ************** @ tk2msftngp13.phx.gbl ...
More......This code is executed on a button click event. If after executing
it, I execute it a second time, the label control populates properly.

Thanks,
John

"jcrouse" <me> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
这是我的代码:

Dim sw As StreamWriter =
File.CreateText(Application.StartupPath&" \mameversion.bat")

sw.WriteLine(lblMameExePath.Text &" -help>"""&
Application.StartupPath&" \ maymeversion.txt""")

sw.Close( )

Dim p As New System.Diagnostics.ProcessStartInfo

p.WindowStyle = ProcessWindowStyle.Hidden

p.FileName = Application.StartupPath& " \ maymeversion.bat"

p.UseShellExecute = True

System.Diagnostics.Process.Start(p)

如果是文件。存在(Application.StartupPath&" \ maymeversion.txt")
然后

Dim sr As StreamReader = New
StreamReader(Application.StartupPath&" \ mameversion.txt")

strLine = sr.ReadLine()

sr.Close()

lblMameVersion.Text = Mid(strLine,11 ,4)

frm1.dblMameVer =
System.Convert.ToDouble(lblMameVersion.Text)

lblMameVersion.Refresh()

结束如果

发生的事情是我正在创建批处理文件,然后执行
批处理文件来创建文本文件。然后我在文本文件里面查看
获取程序的版本号。如果我快速执行代码,版本
号永远不会被写入标签控件。如果我在调试器中单步执行它,它可以正常工作。我认为当我尝试将其写入标签控件时,该版本的运行时速度还是
。我可以在这吗?如果是这样,我如何在代码中暂时停顿?

谢谢,
John

Here is my code:

Dim sw As StreamWriter = File.CreateText(Application.StartupPath & "\mameversion.bat")

sw.WriteLine(lblMameExePath.Text & " -help >""" &
Application.StartupPath & "\mameversion.txt""")

sw.Close()

Dim p As New System.Diagnostics.ProcessStartInfo

p.WindowStyle = ProcessWindowStyle.Hidden

p.FileName = Application.StartupPath & "\mameversion.bat"

p.UseShellExecute = True

System.Diagnostics.Process.Start(p)

If File.Exists(Application.StartupPath & "\mameversion.txt")
Then

Dim sr As StreamReader = New
StreamReader(Application.StartupPath & "\mameversion.txt")

strLine = sr.ReadLine()

sr.Close()

lblMameVersion.Text = Mid(strLine, 11, 4)

frm1.dblMameVer =
System.Convert.ToDouble(lblMameVersion.Text)

lblMameVersion.Refresh()

End If

What is happening is that I am creating the batch file, then executing the
batch file to create the text file. I then look inside the text file to get a version number of the program. If I execute the code fast the version
number never gets written into the label control. If I step through it in
the debugger, it works fine. I think a run-time speed the version is yet to be found when I try to write it to the label control. Could I be correct
here? If so, how do I put a momentary pause in the code?

Thanks,
John



>如果是这样,我如何在代码中暂停一下?


Thread.Sleep(1000)


Greg
>If so, how do I put a momentary pause in the code?

Thread.Sleep(1000)

Greg


为什么不跳过创建和启动批处理文件,直接启动MAME




Dim p As New System.Diagnostics.ProcessStartInfo(lblMameExePath .Text,

" -help>""& Application.StartupPath&" \ maymeversion。 txt""")

p.WindowStyle = ProcessWindowStyle.Hidden

p.UseShellExecute = True

System.Diagnostics .Process.Start(p)


PS:我的是0.81,他们现在的版本是什么? :)


Greg
Why not skip creating and launching the batch file and just launch MAME
directly?

Dim p As New System.Diagnostics.ProcessStartInfo(lblMameExePath .Text,
" -help >""" & Application.StartupPath & "\mameversion.txt""")

p.WindowStyle = ProcessWindowStyle.Hidden
p.UseShellExecute = True
System.Diagnostics.Process.Start(p)

PS: mine was 0.81, what version are they upto nowadays? :)

Greg


这篇关于暂停这里需要的流程吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆