frmkeepitup.vb

来自「Microsoft Mobile Development Handbook的代码」· VB 代码 · 共 36 行

VB
36
字号
Imports Microsoft.VisualBasic
Imports System
Imports System.Windows.Forms
Imports System.Threading

Namespace CodeForChapter11cs
  ' Only run this from within the IDE with F5
  Public Partial Class frmKeepItUp
	  Inherits Form
	Public Sub New()
	  InitializeComponent()
	End Sub

	' start thread that will block
	Private Sub menuItem1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles menuItem1.Click
	  Dim t As Thread = New Thread(AddressOf Me.KeepTheProcessUp)
      't.IsBackground = True
	  t.Start()

	  MessageBox.Show("Hit the Exit button. Is VS still debugging")
	End Sub

	Private Sub KeepTheProcessUp()
	  Dim mre As ManualResetEvent = New ManualResetEvent(False)
	  mre.WaitOne()
	  MessageBox.Show("Never shown!")
	  ' imagine more code
	End Sub

	'Exit
	Private Sub menuItem2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles menuItem2.Click
	  Me.Close()
	  Application.Exit() ' utterly superfluous but just to emphasize the point!
	End Sub
  End Class
End Namespace

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?