Results 1 to 4 of 4

Thread: Running MSComm_onComm and a TcpListener socket in a separate thread hangs program

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2008
    Posts
    4

    Running MSComm_onComm and a TcpListener socket in a separate thread hangs program

    I am working with the MSComm Control in VB.NET, and I also run a TcpListener object in a separate thread to listen for incoming requests in an infinite while loop and call MSComm commands when it has received requests to connect to the comm port, send certain commands through the comm port, and so on.

    My problem is that when the event MSComm_onComm is raised continuously due to the fact that there is a constant stream of data coming in from the comm port, the whole program freezes.

    This problem doesn't occur if I don't have the TcpListener object running, ie. MSComm_onComm runs without any problem at all.

    Would appreciate it anyone could explain what is wrong, as I am a newbie at this, Thanks!

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Running MSComm_onComm and a TcpListener socket in a separate thread hangs program

    Thread Moved
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: Running MSComm_onComm and a TcpListener socket in a separate thread hangs program

    Why are you using TcpListener to listen to a serial port? That's just plain wrong...
    What is your .net version? If you're coding .Net 2.0 or above, you can use the SerialPort class, which will automatically raises an event when it receives data.

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2008
    Posts
    4

    Re: Running MSComm_onComm and a TcpListener socket in a separate thread hangs program

    Sorry if my question wasn't clear.

    I'm using a TcpListener socket because I would like to be able to control the device which is connected through the serial port remotely. Is there a better method?

    I'm using MSComm instead of the SerialPort library because I'm working with a partner's code and he has used MSComm, and I do not have the time now to rewrite his code.

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