Click here to Skip to main content
15,886,795 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionPadding is invalid and cannot be removed Pin
Raheem MA9-Jun-09 4:00
Raheem MA9-Jun-09 4:00 
AnswerRe: Padding is invalid and cannot be removed Pin
Dave Kreskowiak10-Jun-09 1:59
mveDave Kreskowiak10-Jun-09 1:59 
QuestionVB6.0 with Registered OCX control Pin
vhassan9-Jun-09 2:55
vhassan9-Jun-09 2:55 
AnswerRe: VB6.0 with Registered OCX control Pin
Dave Kreskowiak9-Jun-09 6:32
mveDave Kreskowiak9-Jun-09 6:32 
GeneralRe: VB6.0 with Registered OCX control Pin
vhassan9-Jun-09 19:16
vhassan9-Jun-09 19:16 
GeneralRe: VB6.0 with Registered OCX control Pin
Dave Kreskowiak10-Jun-09 1:57
mveDave Kreskowiak10-Jun-09 1:57 
AnswerRe: VB6.0 with Registered OCX control Pin
Jon_Boy9-Jun-09 7:58
Jon_Boy9-Jun-09 7:58 
QuestionProblem with restarting thread Pin
sohaib_a9-Jun-09 2:49
sohaib_a9-Jun-09 2:49 
I have function 'startthread' that points to the thread 'thread1' which is started when I click on button1.
When i click on button2,it is supposed to stop the thread.I want to restart the thread1 but when i click on button 2 again it gives ThreadStateException saying 'Thread is running or terminated; it cannot restart'

What am i doing wrong here?


''To Start the thread
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ds1 As New DataSet
        Dim i As Integer = 0
        ds1 = clsDB.getData("Select * from Readers_test")
       
        Dim s As String = ds1.Tables(0).Rows(0)("Reader_Name").ToString + ":" + ds1.Tables(0).Rows(0)("IP_Address").ToString + ":" + ds1.Tables(0).Rows(0)("Port_No").ToString
    
        'thread1.IsBackground = True
        thread1.Start(s) ''I get exceptio here when I try to restart the thread
    
    End Sub

''To Stop the thread

   Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        
        api.TcpCloseConnect()

        If thread1.IsAlive Then
            thread1.Abort()
        End If
        setValue(Me.TextBox3, "Stopped")
    End Sub




    Private Sub startthread(ByVal state As Object)
      

        Dim timer1 As New System.Timers.Timer
        AddHandler timer1.Elapsed, AddressOf scan
        Dim st As String = state

        Dim status As Integer = 2
        Dim param_arr() As String = st.Split(":")
        Dim Location As String = param_arr(0)
        Dim ReaderIP As String = param_arr(1)
        Dim Port As String = param_arr(2)
        Dim ReaderPort As Integer = Integer.Parse(param_arr(2))

        
        status = api.TcpConnectReader(ReaderIP, ReaderPort)
  
        If status = 0 Then
           

            setValue(Me.TextBox1, "Connected")

            api.ClearIdBuf()
            timer1.Interval = 1000
            loc = Location

            clearbuf = 0
            timer1.Start()
        Else
            setValue(Me.TextBox1, "Not Connected")

        End If

    End Sub


    Public Sub scan(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)
 
        Dim status As Integer = 2
        Dim i As Integer, j As Integer
        Dim IsoBuf As Byte(,) = New Byte(99, 13) {}
        Dim tag_cnt As Byte = 0
        Dim s As String = ""
        Dim s1 As String = ""
        Dim antno As Integer = 5
        Dim tagstatus As String = ""
        Dim tag_flag As Byte = 0
        Dim membank, wordptr, wordcnt As Integer
        membank = 1
        wordptr = 2
        wordcnt = 6
        'Dim value As Byte() = New Byte(15) {}
        Try
            
            status = api.EpcMultiTagIdentify(IsoBuf, tag_cnt, tag_flag)

            'If status1 = 0 Then
            If tag_cnt > 0 Then

                For i = 0 To tag_cnt - 1
                    s1 = String.Format("", TagCnt)
                    For j = 2 To 13
                        s = String.Format("{0:X2}", IsoBuf(i, j))
                        s1 += s
                    Next

                    'Next
                    antno = IsoBuf(i, 1)
                    clearbuf = clearbuf + 1
     
                    setValue(Me.TextBox2, s1)

           
                    If clearbuf = 1 Then
                        api.ClearIdBuf()
                        clearbuf = 0
                    End If
          

                Next

            End If

            TagCnt += 1
       

        Catch ex As Exception
            'MessageBox.Show(ex.ToString)
         
        End Try

    End Sub

AnswerRe: Problem with restarting thread Pin
Johan Hakkesteegt9-Jun-09 3:12
Johan Hakkesteegt9-Jun-09 3:12 
AnswerRe: Problem with restarting thread Pin
LCARS x329-Jun-09 22:43
LCARS x329-Jun-09 22:43 
QuestionReading application .config file Pin
WorkingAcc9-Jun-09 2:36
WorkingAcc9-Jun-09 2:36 
AnswerRe: Reading application .config file Pin
Dave Kreskowiak9-Jun-09 6:28
mveDave Kreskowiak9-Jun-09 6:28 
GeneralRe: Reading application .config file Pin
WorkingAcc10-Jun-09 20:18
WorkingAcc10-Jun-09 20:18 
GeneralRe: Reading application .config file Pin
Dave Kreskowiak11-Jun-09 1:44
mveDave Kreskowiak11-Jun-09 1:44 
GeneralRe: Reading application .config file Pin
WorkingAcc11-Jun-09 1:52
WorkingAcc11-Jun-09 1:52 
QuestionHow can I bring a rare picture format to a picture box? Pin
Sonhospa9-Jun-09 2:16
Sonhospa9-Jun-09 2:16 
AnswerRe: How can I bring a rare picture format to a picture box? Pin
Nagy Vilmos9-Jun-09 2:29
professionalNagy Vilmos9-Jun-09 2:29 
QuestionRe: How can I bring a rare picture format to a picture box? Pin
Sonhospa9-Jun-09 3:03
Sonhospa9-Jun-09 3:03 
AnswerRe: How can I bring a rare picture format to a picture box? Pin
Nagy Vilmos9-Jun-09 3:34
professionalNagy Vilmos9-Jun-09 3:34 
NewsRe: How can I bring a rare picture format to a picture box? Pin
Sonhospa9-Jun-09 5:08
Sonhospa9-Jun-09 5:08 
QuestionFind URL's of Mozila Firefox,Opera or etc Pin
Anubhava Dimri9-Jun-09 2:11
Anubhava Dimri9-Jun-09 2:11 
AnswerRe: Find URL's of Mozila Firefox,Opera or etc Pin
Dave Kreskowiak9-Jun-09 6:24
mveDave Kreskowiak9-Jun-09 6:24 
QuestionCombobox SelectedIndexChanged Infinite Loop Pin
Hypermommy9-Jun-09 2:09
Hypermommy9-Jun-09 2:09 
AnswerRe: Combobox SelectedIndexChanged Infinite Loop Pin
Tom Deketelaere9-Jun-09 2:22
professionalTom Deketelaere9-Jun-09 2:22 
AnswerRe: Combobox SelectedIndexChanged Infinite Loop Pin
binjafar9-Jun-09 2:25
binjafar9-Jun-09 2:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.