|
-
Apr 18th, 2002, 01:47 PM
#1
GetTickcount different in .NET (again)
OK lets try this again, the last post weny goofy.
I use GetTickCount for Timouts in some serial communication with instruments.
PHP Code:
start = GetTickCount
Do
If (GetTickCount - start > 2000) Then
MsgBox ("Light Meter Response Timed Out, TestConnection")
TestConnection = False
mvarReady = False
Exit Function
End If
InBuffer = InBuffer + objMeterComm.Input
Loop Until (InStr(InBuffer, vbCr))
This gave a timeout of approx 2 seconds in VB6
I have to use the following code in .NET to get something anywhere close.
PHP Code:
start = GetTickCount
Do
If (GetTickCount - start > 20000000000) Then
MsgBox("Light Meter Response Timed Out, TestConnection")
TestConnection = False
mvarReady = False
Exit Function
End If
InBuffer = InBuffer + objMeterComm.Input
Loop Until (InStr(InBuffer, vbCr))
Notice the very large number. Is this because .NET returns a larger variable type, and VB6 choped it off?
Any ideas?
-
Apr 18th, 2002, 01:58 PM
#2
OK, I just answered my own question. A long type in .NET is 64 bit not 32 bit,.. So a change in the API declaration to Int32 instead of long fixed the problem right up.
-
Apr 18th, 2002, 02:58 PM
#3
why use api? Once again, the framework provides stuff like this
System.Environment.TickCount
As i tell everyone dont blindly just start transfering API code from VB6 to .NET..make sure it is not possible via the framework first.
-
Apr 18th, 2002, 03:25 PM
#4
Thanks for the info, I do remember reading an article that stated that most all API calls are now in the framework. In this case it is just a matter of I am converting an existing app to get some time with .NET.
Right now all I want to do is get it to work, but i will definately look further into it from now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|