G
gregory_may
I have an application where I am using a System Thread to capture the screen
& Broadcast it to clients. Its "working", but the timing on the background
thread gets wildly erratic at times. Some times, its right away, some times
after 10 seconds. I have included the setup of the process and the outline
of the Call Back Method.
As posted, the callback method can be mildly erratic (only doing a
debug.writeline) I am guessing up to an 80% variance on the time it takes to
print the Debug messages with an average variance of about 15%-25%. It gets
even worse when I add in the real program logic with up to 300% variance on
the loop timing.
If I stop & start the thread, it always clears up the timing for a few
seconds. Then its back to its crazy erratic self.
I think it makes since to try this on another box, but I need to know if my
approach is a good one or if I am doing something wildly silly to start
with.
Thanks!
Setting up the Process:
MyBroadcast = New BroadcastClass(Broad_IPAddress,
Convert.ToInt16(Broad_Port), PollingDelay, BroadcastInterleaveDelay)
MyBroadcast.Background_Capture_Process = New
System.Threading.Thread(AddressOf MyBroadcast.Capture_Process)
MyBroadcast.My_Process_Enabled = True
MyBroadcast.Background_Capture_Process.Start()
Basics of the CallBack Method:
public shared My_Process_Enabled as boolean
Public Sub Capture_Process()
While My_Process_Enabled
Try
For MyLoop = 0 To 5
Next
Debug.WriteLine(" Done:" & TimeOfDay)
Application.DoEvents()
Debug.Flush()
Application.DoEvents()
Threading.Thread.Sleep(Convert.ToInt16(PollingSpeed))
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
End While
End Sub
& Broadcast it to clients. Its "working", but the timing on the background
thread gets wildly erratic at times. Some times, its right away, some times
after 10 seconds. I have included the setup of the process and the outline
of the Call Back Method.
As posted, the callback method can be mildly erratic (only doing a
debug.writeline) I am guessing up to an 80% variance on the time it takes to
print the Debug messages with an average variance of about 15%-25%. It gets
even worse when I add in the real program logic with up to 300% variance on
the loop timing.
If I stop & start the thread, it always clears up the timing for a few
seconds. Then its back to its crazy erratic self.
I think it makes since to try this on another box, but I need to know if my
approach is a good one or if I am doing something wildly silly to start
with.
Thanks!
Setting up the Process:
MyBroadcast = New BroadcastClass(Broad_IPAddress,
Convert.ToInt16(Broad_Port), PollingDelay, BroadcastInterleaveDelay)
MyBroadcast.Background_Capture_Process = New
System.Threading.Thread(AddressOf MyBroadcast.Capture_Process)
MyBroadcast.My_Process_Enabled = True
MyBroadcast.Background_Capture_Process.Start()
Basics of the CallBack Method:
public shared My_Process_Enabled as boolean
Public Sub Capture_Process()
While My_Process_Enabled
Try
For MyLoop = 0 To 5
Next
Debug.WriteLine(" Done:" & TimeOfDay)
Application.DoEvents()
Debug.Flush()
Application.DoEvents()
Threading.Thread.Sleep(Convert.ToInt16(PollingSpeed))
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
End While
End Sub