Interesting chunk of code I wrote
you may or may not find this usefull, but it at least shows multithreading...but run this and type something into the console window and hit enter and the forms Caption will change. This shows how you can run a sub in the bakground listening for something to happen while the program can still function normally.
Code:
REM created on 03/26/2002 at 11:40 AM
Imports System
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Imports System.Threading
Module MainApp
Sub Main(ByVal args() As String)
Application.Run(New MainForm)
End Sub
End Module
Class MainForm
Inherits Form
Private WithEvents btnOne As Button
Private myButt As Button
Private myThread As Thread
Public Sub New()
' Form constructor
btnOne = New Button
btnOne.Name = "myButt"
myButt = btnOne
myButt.Text = "Click Me"
Me.Controls.Add(myButt)
Console.Writeline("Enter a name for the form")
Me.Text = "Test"
myThread = New Thread(AddressOf ListenToConsole)
myThread.Start()
End Sub
Public Sub ListenToConsole()
Do
Me.Text = Console.Readline()
Loop Until False
End Sub