While attempting to develop an application where I have to read data
very fast from the serial port, I am facing some problems. The serial
port data received event seemed fire only every 15 milli-seconds are
so even though I know the data is coming faster than that. To try to
debug the problem I tried to find out how fast I can fire a timer
event. So I created a simple windows forms application with just a
timer control and a button and all the code is below
--------------------------------------------------
Imports System.Threading
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Timer1.Interval = 1 'try changing to different values between
1 millisecond and 500 milliseconds
Timer1.Enabled = Not Timer1.Enabled
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Dim d As Date = DateTime.Now()
With d
TextBox1.AppendText(String.Format("{0:00}:{1:00}:{2:00}.
{3:000}" & vbCrLf, .Hour, .Minute, .Second, .Millisecond))
End With
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
System.Diagnostics.Process.GetCurrentProcess().PriorityClass =
System.Diagnostics.ProcessPriorityClass.Highest
End Sub
End Class
---------------------------------------------------------
When I run it I get the following output in the debug window:
18:31:23.796
18:31:23.812
18:31:23.828
18:31:23.843
18:31:23.859
18:31:23.875
18:31:23.890
18:31:23.906
18:31:23.921
18:31:23.937
18:31:23.953
18:31:23.968
18:31:23.984
18:31:24.000
18:31:24.015
18:31:24.031
18:31:24.046
18:31:24.062
18:31:24.078
18:31:24.093
18:31:24.109
18:31:24.125
18:31:24.140
18:31:24.156
18:31:24.171
----------------------------------
Note the minimum interval is about 15 to 16 msec. I cannot get it to
less than this. Changing the thread priority seems to have NO EFFECT.
Whether I go to 'Highest' priority or 'Idle' priority the timer event
does not fire faster than 15 msec.
Is this fundamental problem with .NET or with Windows? What else can I
do improve the response?
Thanks
Robert
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/DotNetDevelopment
You may subscribe to group Feeds using a RSS Feed Reader to stay upto date
using following url
<a href="http://feeds.feedburner.com/DotNetDevelopment">
http://feeds.feedburner.com/DotNetDevelopment</a>
-~----------~----~----~----~------~----~------~--~---