Results 1 to 4 of 4

Thread: GetTickcount different in .NET (again)

  1. #1
    Ergo60
    Guest

    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 2000Then
          MsgBox 
    ("Light Meter Response Timed Out, TestConnection")
          
    TestConnection False
          mvarReady 
    False
          
    Exit Function
        
    End If
        
    InBuffer InBuffer objMeterComm.Input
      Loop Until 
    (InStr(InBuffervbCr)) 
    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 20000000000Then
            MsgBox
    ("Light Meter Response Timed Out, TestConnection")
            
    TestConnection False
            mvarReady 
    False
            
    Exit Function
          
    End If
          
    InBuffer InBuffer objMeterComm.Input
        Loop Until 
    (InStr(InBuffervbCr)) 

    Notice the very large number. Is this because .NET returns a larger variable type, and VB6 choped it off?

    Any ideas?

  2. #2
    Ergo60
    Guest
    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.

  3. #3
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    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.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  4. #4
    Ergo60
    Guest
    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
  •  



Click Here to Expand Forum to Full Width