Visual Basic - Null Reference Exception

Life is soft - evento anual de software empresarial
 
Vista:

Null Reference Exception

Publicado por Gustavo (3 intervenciones) el 15/05/2009 17:50:53
Hola les escribo porque tengo un NullReferenceException en mi clase que me crea el hilo para levantar un servicio de Windows, este es el codigo que estoy usando para crear la clase ThreadWrapper:

Namespace NP.Multithreading
Public MustInherit Class ThreadWrapper
Private myThread As System.Threading.Thread
Private intervalo As Integer = CInt(System.Configuration.ConfigurationManager.AppSettings.Item("UpdateInterval").ToString())

Protected MustOverride Sub DoWork()
Public Sub Start()
myThread = New Threading.Thread(AddressOf ThreadMethod)
myThread.Name = "myThread" & myThread.ManagedThreadId
myThread.IsBackground = True
Try
myThread.Start()
Catch ex As Threading.ThreadStartException
WriteToEventLog(ex)
End Try
End Sub

Public Sub Abort()
Try
myThread.Abort()
Catch ex As System.Threading.ThreadAbortException
Finally
myThread = Nothing
End Try
End Sub

Private Sub ThreadMethod()
Do While True
If My.Computer.Network.IsAvailable = True Then
DoWork() 'EXCEPTION
End If
System.Threading.Thread.Sleep(intervalo)
Loop
End Sub

Public Sub WriteToEventLog(ByVal ex As Exception)
EventLog.WriteEntry(K_APP_NAME, ex.Message & "." & ex.InnerException.Message)
End Sub
End Class
End Namespace

el error que me da es el siguiente:

System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="MotoStoreUpdate"
StackTrace:
at MotoStoreUpdate.NP.Multithreading.ThreadWrapper.WriteToEventLog(Exception ex)
at MotoStoreUpdate.UpdateBase.DoWork()
at MotoStoreUpdate.NP.Multithreading.ThreadWrapper.ThreadMethod()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Si alguien me pudiera ayudar con esto por favor.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder