dadibarca23
New member
- Joined
- Apr 12, 2016
- Messages
- 2
- Programming Experience
- 1-3
hey everyone. can anyone tell me how to call a function from a secondary thread. in my program, i have a background worker running. when the user clicks a button on the main form
Does not make any reaction and Thanks
Does not make any reaction and Thanks
Private Sub BackgroundWorker1_DoWork(sender As Object, e As DoWorkEventArgs) Handles BGW.DoWork soldDJEZZY() End Sub Private Sub BGW_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles BGW.ProgressChanged TextBox5.Text = e.UserState.ToString End Sub 'buton solde djezzy Private Sub Button26_Click(sender As Object, e As EventArgs) Handles Button26.Click If Not BGW.IsBusy Then BGW.RunWorkerAsync() End Sub Sub soldDJEZZY() strCommand = String.Format("AT+CUSD=1," & Chr(34) & "{0}" & Chr(34) & ",15", "*" & parrametre.TextBox9.Text & "#") Dim strName As String = parrametre.cbxDevices2.Text() Dim iDeviceSpeed As Integer If (Not Integer.TryParse(parrametre.cbxDeviceSpeed2.Text, iDeviceSpeed)) Then iDeviceSpeed = 0 End If objGsm.Open(strName, "0000", iDeviceSpeed) If (objGsm.LastError <> 0) Then If (objGsm.LastError = 36103) Then MessageBox.Show("Invalid Pin entered: SIM card can be blocked after a number of false attempts in a row.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error) End If End If ' Sends the USSD Command though the selected GSM Modem If (objGsm.LastError = 0) Then objGsm.SendCommand(strCommand) End If ' Reads the response from the GSM Modem If (objGsm.LastError = 0) Then strResponse = objGsm.ReadResponse(10000) End If If (objGsm.LastError = 0) Then If (strResponse.Contains("OK")) Then ' Response should be OK objGsm.SendCommand(String.Empty) strResponse = objGsm.ReadResponse(10000) If (objGsm.LastError <> 0) Then UpdateResult2(objGsm.LastError) Return End If If (strResponse.Contains("+CUSD:")) Then strFields = strResponse.Split(Char.Parse(Chr(34))) If (strFields.Length > 1) Then strResponse = strFields(1) Else strResponse = strFields(0) End If End If End If End If BGW.ReportProgress(0, strResponse) TextBox5.Text = (strResponse) UpdateResult2(objGsm.LastError) objGsm.Close() 'Cursor = Cursors.Default End Sub
Last edited by a moderator: