• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

C# to C++ callback problem

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    #11
    Ah, now it makes sense. I've never seen anyone put a loop like that into a function called "registerCallback" before

    I thought you meant you registered the callback and then there was a thread in the DDL that called it.

    Why don't you just do away with the callback and put a loop in the mangled ^H^H^H^H aged code to call "getSomeData" every two seconds? That way you could perhaps pass in a reference to the destination structure and the marshalling would go more smoothly.
    While you're waiting, read the free novel we sent you. It's a Spanish story about a guy named 'Manual.'

    Comment


      #12
      Originally posted by doodab View Post
      Ah, now it makes sense. I've never seen anyone put a loop like that into a function called "registerCallback" before

      I thought you meant you registered the callback and then there was a thread in the DDL that called it.

      Why don't you just do away with the callback and put a loop in the mangled ^H^H^H^H aged code to call "getSomeData" every two seconds? That way you could perhaps pass in a reference to the destination structure and the marshalling would go more smoothly.
      The function is a stub, that I am using to test my .net app. Ultimately it will be connected up to my WFP driver, and it will be callback based.
      Knock first as I might be balancing my chakras.

      Comment


        #13
        Originally posted by suityou01 View Post
        The function is a stub, that I am using to test my .net app. Ultimately it will be connected up to my WFP driver, and it will be callback based.
        The function in the DLL or the .Net app will be connected to the driver?

        I am presuming the DLL will be handling IO to the driver device and then the .Net app will be using the DLL as above?
        While you're waiting, read the free novel we sent you. It's a Spanish story about a guy named 'Manual.'

        Comment


          #14
          Originally posted by doodab View Post
          The function in the DLL or the .Net app will be connected to the driver?

          I am presuming the DLL will be handling IO to the driver device and then the .Net app will be using the DLL as above?
          Yep that's it. I tried having the .net app talking direct to the driver but despite microsoft's claims, it just isn't as quick as unmanaged (native) code, fact. So this dll should handle all the io flak from the driver, and only pass important stuff up to the front end.

          Or so the theory goes.
          Knock first as I might be balancing my chakras.

          Comment


            #15
            Why don't you just do the DLL in C++ CLR? Then you can make the interface all .NET, and still call the native code.
            Will work inside IR35. Or for food.

            Comment


              #16
              Originally posted by VectraMan View Post
              Why don't you just do the DLL in C++ CLR? Then you can make the interface all .NET, and still call the native code.
              Then you still have the problem of accessing the driver from managed code.
              While you're waiting, read the free novel we sent you. It's a Spanish story about a guy named 'Manual.'

              Comment


                #17
                Originally posted by doodab View Post
                Then you still have the problem of accessing the driver from managed code.
                No you don't. C++ means you can mix and match managed and unmanaged in the same function.

                Did it work in the end? Looking back at the code, the thing that jumps out at me is that you're passing a FIREWALL_MESSAGE that's on the stack. I didn't think you'd be able to pass a delegate in either, but obviously you can.
                Will work inside IR35. Or for food.

                Comment


                  #18
                  Originally posted by VectraMan View Post
                  No you don't. C++ means you can mix and match managed and unmanaged in the same function.

                  Did it work in the end? Looking back at the code, the thing that jumps out at me is that you're passing a FIREWALL_MESSAGE that's on the stack. I didn't think you'd be able to pass a delegate in either, but obviously you can.
                  How do you do that? I thought the boundary was always at a function call i.e. you could have managed and unmanaged functions in a mixed assembly but each function is either managed or unmanaged.

                  Good point though, the code might be easier to read and write.
                  While you're waiting, read the free novel we sent you. It's a Spanish story about a guy named 'Manual.'

                  Comment


                    #19
                    Originally posted by VectraMan View Post
                    No you don't. C++ means you can mix and match managed and unmanaged in the same function.

                    Did it work in the end? Looking back at the code, the thing that jumps out at me is that you're passing a FIREWALL_MESSAGE that's on the stack. I didn't think you'd be able to pass a delegate in either, but obviously you can.
                    Thank VM will look into this.
                    Knock first as I might be balancing my chakras.

                    Comment

                    Working...
                    X