Break processing of procedure

Hi,

In very rare cases processing of a button-onclick (send E-mail) procedure freezes on a customer's PC. Till now I haven't been able to trace the cause of this behaviour, but it is of the essence that my application doesn't have to be shutdown (the hard way) in order to preserve some data.

Therefore I want to add an option for the user to KILL the process, without the need to end program execution.

Can anybody advice me on how to accomplish this?
Stef MerlijnDeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SteveBayCommented:
Have you tried putting a try/except wrapper in your Button OnClick event handler?
0
Stef MerlijnDeveloperAuthor Commented:
Yes, but there is no error. It freezes at some point in the process.
0
SteveBayCommented:
You say it is sending an Email. How are you doing that? MAPI?
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Stef MerlijnDeveloperAuthor Commented:
I'm using components from Clever Components Suite. Sending is done directly via SMTP.
0
Sinisa VukCommented:
Have you contact Clever Components developers? They might help you. They know things under the hood ....
0
Stef MerlijnDeveloperAuthor Commented:
Yes, we did some logging, but nothing out of the ordinairy.
That's why I ask my question. I ran out of options for now.
0
SteveBayCommented:
I don't know Clever Comp.

Freezing does not necessarily equal crash. Perhaps the component is somehow getting into an endless loop.  

If you can't fix the freeze... let me suggest a different approach: Maybe you could create a fail-safe file that contains critical recovery data before starting your Email process. If the process succeeds (doesn't freeze) you delete the file. If the file exist upon restart then you know the program had to be crashed, therefore you know that you need to apply the recovery data before continuing. I know it's kind of an ugly work-around, of course the best solution is to not freeze in the first place.
0
Stef MerlijnDeveloperAuthor Commented:
The only way I could recover as suggested, I would need to copy DB-records just before mailing. But in a multi user environment it's not very reliable/useful.

I prefer to terminate the mailing somehow.
0
SteveBayCommented:
Another idea would be to run your email process in a thread. If the thread does not terminate after a *reasonable* amount of time you might be able to  forcefully terminate the thread.
http://stackoverflow.com/questions/4044855/how-to-kill-a-thread-in-delphi
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sinisa VukCommented:
... or you can use Indy components....
0
Stef MerlijnDeveloperAuthor Commented:
Thank you!
0
Stef MerlijnDeveloperAuthor Commented:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.