when I use C.dll call golang func, the programm will stuck. My golang code 
is :

import (

     "C"

    "fmt"

    "syscall"

    "unsafe"

)

var times int

func main() {

    cbStr := syscall.NewCallback(goCbStr)

    dll, error := syscall.LoadDLL("test0001.dll")

    fmt.Println(dll)

    var initConnAgent *syscall.Proc

    initConnAgent, error = dll.FindProc("init")

    fmt.Println(initConnAgent, error)

    //    unsafe.

    initConnAgent.Call(uintptr(unsafe.Pointer(&cbStr)))

   //fmt.Println(r1, r2, lerr)

    for {


    }


}


func goCbStr(callId int, funtype int, str *C.char) uintptr {

    times++

    fmt.Println(times, callId, funtype, C.GoString(str))

    return uintptr(0)

}





my c.dll code is :
void timeProc(void*P);

ADAPTERDLL_API void init(cbStr* p) {
goCallback = *p;
printf("init success!\n");
_beginthread(&timeProc, 0, 0);
printf("End \n");
}

void timeProc(void *p) {
for (;;) {
goCallback(1, 2, "Hello");
}
}


when I execute the exe, the Programm can only print about 47103 times. My 
question is:

   1. 
   
   How many times C.dll can call golang func ?
   2. 
   
   if I can call golang func infinitely , What errors I did?
   3. 
   
   
   

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to