CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Dll

  1. #1
    Join Date
    May 1999
    Posts
    3

    Dll

    Hi,


    I have created a set of dlls that will do a batch processing job which requires a lot of time. During the processing if I want to cancel the job, I have provided a Cancel button. Now my problem is how does the dll get to know that the cancel button has been clicked.

    Thanks.



  2. #2
    Join Date
    Apr 1999
    Location
    Rotterdam, Netherlands
    Posts
    278

    Re: Dll

    Hi
    I would use an event, since I would use an event anyway to know the status of the process. You can use a parameter to indicate to stop or not.
    Or use a Cancel method in one of the classes., and check during that process if the cancel boolean is set
    Hope this helps :-)
    Crazy D :-)


  3. #3
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: Dll

    Hi,

    You have to 'design' the dlls to handle this style of functioning. A couple of questions arise:
    1. Are the dlls VB or VC?
    2. Do the dlls have any UI, like popping up a dialog box etc?

    If they are VB, then you can use
    1. Call "DoEvents" to relinquish control at points of processing that makes sense - meaning at points where stopping doesnt cause internal (state) inconsistencies of data, and check if the user had pressed cancel by looking at a variable...

    ...
    m_cancelnow = false ' at start of processing
    '... some where ...
    DoEvents
    if m_cancelnow then goto ExitProcessing..
    ...
    private sub CancelBtn_CLick()
    m_cancelnow = true
    end sub




    This method can have 'hung' look, if your DoEvents are sparce => user would press "Cancel" but , the btn would not even "go down&up."

    2. If they are VC, it is a bit more difficult to relinquish control, because each dll call is like one single step of execution from VB's point of view. If they dont contain UI, then i would design them to run on a worker thread, using "CreateThread". This way my VB app will look more "alive" meaning responding to user (cancel) clicks fast. and i would design my processing to occasionally look at a dll-global/a member in param structure variable to quit the processing ( & exit thread automatically)

    3. Creating UI threads on VC is difficult.
    If VB, i would go for Activex (server) Exe.

    4. For both VC & VB you can use the all powerful "GetAsyncKeyState" to check if any keyboard/mouse activity and take approp actn. It requires some doing though!.

    Hope it was useful!

    If your processing takes a lot of time, Dont you want to inform your uses abt progress with some indicators? :-)

    Ravi


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured