- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有没有办法在屏幕上没有 UI 的情况下做到这一点?目前,我正在让这个小型非 UI 程序每 60 秒从 3270 大型机读取和写入文本文件的信息,假设用户想在 60 秒等待的中间取消,我怎么能“听”没有来自 UI 的任何事件的按键?
最佳答案
您需要某种界面来捕获击键。
这是在控制台应用程序中运行的示例(创建一个空白并粘贴到 defauklt 模块)
它允许在后台线程中处理“某事”,同时让 GUI 空闲以供用户输入命令。在这种情况下,只需一个简单的 1 秒延迟计数器即可达到 1000。
选项比较文本
Module Module1
Sub Main()
Console.WriteLine("Enter ""Start"", ""Stop"", or ""Exit"".")
Do
Dim Com As String = Console.ReadLine
Select Case Com
Case "Start"
Console.WriteLine(StartWork)
Case "Stop"
Console.WriteLine(StopWork)
Case "Exit"
Console.WriteLine("Quiting on completion")
Exit Do
Case Else
Console.WriteLine("bad command Enter ""Start"", ""Stop"", or ""Exit"".")
End Select
Loop
End Sub
Public Function StartWork() As String
If ThWork Is Nothing Then
ThWork = New Threading.Thread(AddressOf Thread_Work)
ThWork.IsBackground = False 'prevents killing the work if the user closes the window.
CancelWork = False
ThWork.Start()
Return "Started Work"
Else
Return "Work Already Processing"
End If
End Function
Public Function StopWork() As String
CancelWork = True
If ThWork Is Nothing Then
Return "Work not currently running"
Else
Return "Sent Stop Request"
End If
End Function
Public CancelWork As Boolean = False
Public ThWork As Threading.Thread = Nothing
Public dummyCounter As Integer = 0
Public Sub Thread_Work()
Try
Do
dummyCounter += 1
Console.Title = "Working ... #" & dummyCounter
' ###############
' do a SMALL PART OF YOUR WORK here to allow escape...
' ###############
If dummyCounter >= 1000 Then
Console.Title = "Work Done at #" & dummyCounter
Exit Do
ElseIf CancelWork Then
Exit Do
End If
Threading.Thread.Sleep(1000) ' demo usage only.
Loop
Catch ex As Exception
Console.WriteLine("Error Occured at #" & dummyCounter)
End Try
ThWork = Nothing
If CancelWork Then
Console.Title = "Work Stopped at #" & dummyCounter
End If
End Sub
End Module
关于vb.net - 在线程休眠时“监听”按键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16906006/
这个问题在这里已经有了答案: What is the JavaScript version of sleep()? (91 个回答) 关闭 9 年前。 是的,我知道 - 这个问题有成千上万的答案。请
有没有办法使用 native NHibernate linq 提供程序执行以下查询? var result = (from e1 in Session.Query() join e2
上下文:我正在尝试将Grails项目从1.0.3升级到1.3.7,并且遇到了很多问题。我刚得到很多DuplicateMappingExceptions,因为该项目同时具有Hibernate XML文件
我有标准: ICriteria criteria = Session.CreateCriteria() .SetFetchMode("Entity1", FetchMo
我正在寻找一种重新启动线程的方法,无论是从该线程的上下文内部还是从线程外部,可能是从另一个进程中。 (这些选项中的任何一个都可以。)我知道使整个进程休眠的困难,而且我很确定线程也会遇到同样的困难。但是
C 中是否有任何函数可以检查计算机是否进入 sleep 、休眠 或锁定 并从这些状态唤醒? 在msdn它们为 C#、C++ 提供,但不为 C 提供。我的操作系统是windows7 如下是我用来检查启动
我对 NHibenate 有疑问。当我运行 queryover 时,出现错误“无法解析属性:User.Name of:MegaOnlineChat.Core.Entities.Message”。我做错
我知道这里被问过很多次,也回答过很多次,这不是应该如何完成的方式,但再一次:) 是否有可能以某种方式调用异步函数(例如计时器/ajax 调用),基本上是常见的异步任务并同步等待直到它结束而不会出现 1
我在persistence.xml中有以下内容 com.merc.model.log.EventLogging org.hibernate.ejb.HibernatePersiste
目前我的存储库有 2 个构造函数。当我从我的 mvc 网站调用这些时,我总是调用第一个构造函数,从而打开一个新 session 。我应该在 session 中通过吗?我该怎么做。 public
hibernate session to list conversion Compilation Error occured when java converted into scala..!!
下面的remove()方法导致“超出了GC开销限制”。从A或B或C中删除ABC中存在的关联时。请您告知错误在哪里吗? 注-ABC是A,B,C的映射表 stacktrace如下: Caused by:
昨天我在 webhosting.net 的 Jelastic v2.2.2 上获得了一个试用帐户,并配置了一个最少 0 个 cloudlets 的环境(最多 8 个,即全部动态,无保留)。然后我部署了
设置:Grails 2.5.6和Hibernate 4.3.10 我有一个带有字符串ID的表。事实是,它的值是数字字符串,当我传入诸如get()这样的值时,这似乎使"000000"变得混乱。 域类:
hibernate session to list conversion Compilation Error occured when java converted into scala..!!
我有一个用于 PDA 的应用程序,它有一个长时间运行的进程,我遇到了一个问题,即 PDA 将在该进程完成之前进入休眠状态。 我无法控制 PDA 上的电源设置,有谁知道我的应用程序阻止 PDA 进入休眠
我正在创建一个将安装在 LaunchAgents 文件夹中的守护程序。关于使其 sleep 的一些问题: 因为它是一个 LaunchAgent 项,所以可执行文件会在用户/系统 sleep 时自动 s
我想使用 AsyncTask 创建启动画面。具体来说,在 doInBackground() 方法中,我使用静态方法 Thread.sleep() 并在它创建一个将应用程序重定向到其他 Activity
在我的网站上,我有一个 JavaScript 函数,它执行 AJAX 调用来获取帐户信息,然后打开一个模式,您可以在其中查看和编辑信息。 AJAX 调用用于更改您选择的数据库中的详细信息,然后刷新原始
除非线程告诉我醒来,否则我想睡 X 时间。在下面的示例中,我想休眠 10 毫秒(1/100 秒)或直到 foo 有 2000 个项目。以先到者为准。我该怎么做呢?我编了函数 主线程: pthread_
我是一名优秀的程序员,十分优秀!