how to stop dll

Discussion in 'C' started by arunkani, Jan 13, 2009.

  1. arunkani

    arunkani New Member

    Joined:
    Jan 13, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    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?
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    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.
     
  3. arunkani

    arunkani New Member

    Joined:
    Jan 13, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    ok,
    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
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Only if the DLL is threadsafe; did you write it that way?
    If not then it almost certainly won't be.
     
  5. arunkani

    arunkani New Member

    Joined:
    Jan 13, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    thanks sir
    In c, can we create threaded dll?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice