Hi,
I am attempting to spawn a thread and use it to write an NV. However, I am gettin the error "InvalidNetworkVariableNameError" when I try to perform the .connect. What does this error mean? The location I'm trying to write to (held in the string variable NetworkVariableLocation) is correct.
Here's a snippet of the code i'm using.
Public Sub thread_heartBeat()
Dim HBeatValue As Double
Dim NV As New NVReadWrite
' Do this until the thread is canceled.
Do
' This is used as a semaphore telling this thread
' whether or not to write the heartbeat.
If go Then
HBeatValue = System.DateTime.Now.ToOADate
Dim NetworkVariableLocation As String
NetworkVariableLocation = path
Dim NVWriter As New NetworkVariableWriter(Of Double)(NetworkVariableLocation)
Try
NVWriter.Connect()
NVWriter.WriteValue(HBeatValue)
NVWriter.Disconnect()
Catch currentError As Exception
' Log the problem here
End Try
End If
' Wait 2 seconds then send the heartbeat again.
System.Threading.Thread.Sleep(2000)
Loop
End Sub
Any suggestions would be helpful. Thanks.