Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   how to stop dll (http://www.go4expert.com/forums/stop-dll-t15808/)

arunkani 13Jan2009 12:20

how to stop dll
we have created a dll in c.
From java we are calling that c dll.
The dll is linking and running properly
In the middle of the execution, how we can stop the dll and return the control to java?

xpi0t0s 13Jan2009 14:33

Re: how to stop dll
In short: no, you have to rewrite the DLL code to work how you want it to.

You can't force a function to return. What you could do perhaps is to call the DLL function that's not returning in a timely manner in a separate thread, then when you want it to stop you just kill the thread. But that's not likely to be a good solution. As you wrote the DLL, probably the best way is to turn any loop control over to the caller so that any repetition the DLL function does is actually controlled by the Java program, then if you don't want it to repeat you just stop calling it, making sure to add any cleanup code that may be necessary.
Alternatively if the DLL is threadsafe you could add a "stop running" function and add a check within the code that isn't returning for whether or not that function has been called.

arunkani 13Jan2009 15:00

Re: how to stop dll
while executing the first function of c dll (using a java thread), can we call the next function of that dll by using separate java thread

xpi0t0s 13Jan2009 20:53

Re: how to stop dll
Only if the DLL is threadsafe; did you write it that way?
If not then it almost certainly won't be.

arunkani 16Jan2009 15:40

Re: how to stop dll
thanks sir
In c, can we create threaded dll?

All times are GMT +5.5. The time now is 04:09.