Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to call C++ parameterised function from C# using thread

How to call C++ parameterised function from C# using thread

Scheduled Pinned Locked Moved C#
tutorialcsharpc++
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sjs4u
    wrote on last edited by
    #1

    Hi, I want to call parameterised function which is written in c++ from c# by using thread and also how will c# know or will get return value from c++ function, so that c# function will proceed further. If you have any example then let me know. Thanks sjs

    L D 2 Replies Last reply
    0
    • S sjs4u

      Hi, I want to call parameterised function which is written in c++ from c# by using thread and also how will c# know or will get return value from c++ function, so that c# function will proceed further. If you have any example then let me know. Thanks sjs

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You can use P/Invoke[^] to call C++ functions within a DLL.

      One of these days I'm going to think of a really clever signature.

      1 Reply Last reply
      0
      • S sjs4u

        Hi, I want to call parameterised function which is written in c++ from c# by using thread and also how will c# know or will get return value from c++ function, so that c# function will proceed further. If you have any example then let me know. Thanks sjs

        D Offline
        D Offline
        DaveyM69
        wrote on last edited by
        #3

        Something like this:

        [DllImport("yourdllname.dll")]
        public static extern returnType FunctionName(parameterType parameter);

        To call it on a thread, call BeginInvoke on a ParameterizedThreadStart instance that in turn calls your PInvoke function.

        Dave
        Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
        BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups