Results 1 to 28 of 28

Thread: [RESOLVED] HELP with MultiThreading

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    310

    Resolved [RESOLVED] HELP with MultiThreading

    Hi, I am new in vb.Net

    It is my previous problem in vb6, its hard to multithread using vb6 so I migrate my codes to vb.Net.

    How can I multithread this two loops so that this process is running at the same time.
    Because when I start my second Loop, my first loop stop in executing. It will start again when my 2nd loop finished.

    Here is my 2 Loops:

    Code:
    Dim Ret As Integer
            Dim i As Short
            For i = 0 To ListBox1.Items.Count - 1
                System.Windows.Forms.Application.DoEvents()
                ListBox1.SelectedIndex = i
                ListBox1.Refresh()
    
                WriteToLog("Sending SMS to ->  " & txtDestination.Text, System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Yellow))
    
                Ret = Device.SendSMS(txtDestination.Text, txtmsg.Text)
                Device.GetLastError(0)
                If Ret > 1 Then
                    WriteToLog("SMS Sent to ->  " & txtDestination.Text, System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Lime))
                End If
                If Ret = -22 Then
                    WriteToLog("ERROR Sending to ->  " & txtDestination.Text, System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red))
                    WriteToLog("ERROR: PDU error, Signal, Check Account balance.", System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red))
                End If
                If Ret = -20 Then
                    WriteToLog("ERROR Sending to ->  " & txtDestination.Text, System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red))
                    WriteToLog("ERROR: SMS Service, Check Account balance.", System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red))
                End If
                If Ret = -19 Then
                    WriteToLog("ERROR Sending to ->  " & txtDestination.Text, System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red))
                    WriteToLog("ERROR: SMSC NOT FOUND.", System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red))
                End If
                If Ret = -2 Then
                    WriteToLog("ERROR Sending to ->  " & txtDestination.Text, System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red))
                    WriteToLog("ERROR: PORT FAIL.", System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red))
                End If
            Next

    Code:
    Dim Ret2 As Integer
            Dim j As Short
            For j = 0 To ListBox2.Items.Count - 1
                System.Windows.Forms.Application.DoEvents()
                ListBox2.SelectedIndex = j
                ListBox2.Refresh()
    
                WriteToLog2("Sending SMS to ->  " & txtDestination2.Text, System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Yellow))
    
                Ret2 = Device2.SendSMS(txtDestination2.Text, txtmsg.Text)
                Device2.GetLastError(0)
                If Ret2 > 1 Then
                    WriteToLog2("SMS Sent to ->  " & txtDestination2.Text, System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Lime))
                End If
                If Ret2 = -22 Then
                    WriteToLog2("ERROR Sending to ->  " & txtDestination2.Text, System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red))
                    WriteToLog2("ERROR: PDU error, Signal, Check Account balance.", System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red))
                End If
                If Ret2 = -20 Then
                    WriteToLog2("ERROR Sending to ->  " & txtDestination2.Text, System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red))
                    WriteToLog2("ERROR: SMS Service, Check Account balance.", System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red))
                End If
                If Ret2 = -19 Then
                    WriteToLog2("ERROR Sending to ->  " & txtDestination2.Text, System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red))
                    WriteToLog2("ERROR: SMSC NOT FOUND.", System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red))
                End If
                If Ret2 = -2 Then
                    WriteToLog2("ERROR Sending to ->  " & txtDestination2.Text, System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red))
                    WriteToLog2("ERROR: PORT FAIL.", System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red))
                End If
            Next
    I have 2 connected GSM Modem in usb port.
    That codes will send SMS in all contacts in my ListBox.
    Last edited by dr_aybyd; Jun 28th, 2009 at 09:11 AM.
    VB 6.0 = "Self-Study" Then
    vb.NET = "Self-Study" Then
    C# = 'on going study.....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width