Click to See Complete Forum and Search --> : Dll


Varghese
May 26th, 1999, 06:01 PM
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.

Crazy D
May 26th, 1999, 06:26 PM
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 :-)

Ravi Kiran
May 26th, 1999, 09:50 PM
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