Search code examples
.netmultithreadingwindows-phone-7backgroundworkercode-behind

In a class is a variable not accessable from other thread


I have an byte array declared in the header of the class. When I want to access it in the audio event Methode of the microphone the array is NOTHING and not available in this class on this point.

Any idea how to declare the array to get access in the other thread?

Regards

Private Class Test1234
Private BufferData(1023) As Byte

Private Sub microphone_BufferReady(sender As Object, e As System.EventArgs) Handles microphone.BufferReady
        ' Retrieve audio data
        microphone.GetData(Me.BufferData)'<-- Is NOTHING
End Sub
End Class

I am asking why Me.BufferData is nothing when I am in the microphone Event. Because it is pre-set on initilizing routine with a size of 1024 Bytes


Solution

  • Your BufferData is never initialized, just declared

    BufferData As New Byte(1023)