Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
May 2, 1999

Canceling a call to a dll

Question:
In a program, I'm calling a function in a dll. The time before that function is finished can vary from a few seconds to an hour, depending on the start values and how big the problem is.

I want the user to be able to cancel if he/she thinks it takes too long, and perhaps start over with other start values.

I've tried to call the dll in a thread, using createThread, and then closing the thread when the user presses the cancel button. But I get strange errors, and I can't find where they occur.

Is there another way to cancel a call to a dll? Or is there a good example of how to solve it with a thread somewhere?

Answer:
Here's one way to do it. Declare an event in the DLL with a Boolean parameter. In the long running function, periodically raise the event and check the Boolean parameter to see whether the user canceled it.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date