Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can't figure out why ArrayList.RemoveAt() is not working
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Can't figure out why ArrayList.RemoveAt() is not working
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2008 Server
Application:
Desktop
Miscellaneous
Thread ID:
01519460
Message ID:
01519460
Views:
82
I am currently using Florian Leitner's HID USB library in my VB.NET solution for communicating with a pin pad. As per his sample code, I set up an event handler to handle incoming responses from the device which are stored in an ArrayList called usbBuffer:
    Private Sub BufferEventHandler(ByVal sender As Object, ByVal e As System.EventArgs)

        If USBInterface.usbBuffer.Count > 0 Then

            While USBInterface.usbBuffer(0) Is Nothing

                SyncLock USBInterface.usbBuffer.SyncRoot

                    USBInterface.usbBuffer.RemoveAt(0)

                End SyncLock

            End While

            _receiveArray = CType(USBInterface.usbBuffer(0), Byte())

            _usbInterface.stopRead()

            SyncLock USBInterface.usbBuffer.SyncRoot

                USBInterface.usbBuffer.RemoveAt(0)

            End SyncLock

        End If

    End Sub
The problem is that the RemoveAt is not working, since the first element in the list remains there after the handler is done. Could someone please advise as to what I've done wrong, or perhaps use a different approach?
Jon Rosenbaum
Devcon Drummer
Next
Reply
Map
View

Click here to load this message in the networking platform