CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2002
    Posts
    57

    Console Applications, message pumps, interthread comms

    I'm new to the world of C#, my current employer wants me to write a program in C# (VS2008 .NET 3) when normally I'd use VC++.

    The code that I'm writing has no GUI but will have several threads which need to communicate with each other. The code for one of these will be provided by a COM DLL.

    I have several questions:

    1. What is the best method for inter-thread comms and data transfer in C#?

    2. In the case of user defined windows message handling, is there a C# equivalent of the PeekMessage pump style code?

    3. Is there an equivalent to SendMesssage and PostMessage in C#.

    4. If the COM DLL is written using unmanaged code (VC++ version 6) will I encounter any problems when referring to it in C# or does C# behave similarly to VB in this respect.

    Any answers or references would be most helpful.

    Cheers.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Console Applications, message pumps, interthread comms

    Quote Originally Posted by brandwooddixon
    I'm new to the world of C#, my current employer wants me to write a program in C# (VS2008 .NET 3) when normally I'd use VC++.

    The code that I'm writing has no GUI but will have several threads which need to communicate with each other. The code for one of these will be provided by a COM DLL.

    I have several questions:

    1. What is the best method for inter-thread comms and data transfer in C#?

    2. In the case of user defined windows message handling, is there a C# equivalent of the PeekMessage pump style code?

    3. Is there an equivalent to SendMesssage and PostMessage in C#.

    4. If the COM DLL is written using unmanaged code (VC++ version 6) will I encounter any problems when referring to it in C# or does C# behave similarly to VB in this respect.

    Any answers or references would be most helpful.

    Cheers.
    Questions back to you.
    1) How did you do this in C++?
    2) Although you can pInvoke to these messaging api's generally you use delegates and events in C# (rather than sending messages).
    3) Pinvoke to these, but see 2).
    4) If it was in VB (via IDispatch), it should work in C#.

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

Featured