Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cancel a long running process
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
00945712
Message ID:
00945869
Vues:
19
David,

Thank you for the reply! I am trying to accomplish this through events and delegates, but I am missing something?

I worked with Kevin to develop a progress bar that can be dropped on a form and updated from the business object. Here are the steps:

1. The business object has an event called Progress
2. There is a delegate called ProgressDelegate
3. The event arguments are called ProgressEventArgs
4. There is a method in the business object called OnProgress that fires the Progress event

The progress bar is registered as a listner, but I am not sure how to register the form as a listner and then test for the escape key.

Kind Regards,

Mat

>Windows forms work with a single thread of execution by default. If that single thread is busy executing a method on the business object then your windows events will get queued up in the message queue until the method is done processing (the dreaded hourglass icon).
>
>There are a couple of things you can do. If there is a convenient place in your long running loop, you may be able to place an Application.DoEvents in the loop which will allow the message queue to get serviced. I think a better way is to execute the business object's method on a worker thread (see Thread.Start) and let it raise events that the main ui thread can listen to. Then you could send the worker thread a cancel message which would allow it to cancel gracefully.
>
>Be aware that the only thread that updates a ui control should be the one that created it. Hopefully that will give you enough background to research these ideas on the net. If I can dig up some code i'll post it.
>
Matthew Kennedy
Decision Support Technology Inc.

"I try to take one day at a time, but sometimes several days attack me all at once." ~ Ashleigh Brilliant

New Jersey Dot Net User Group
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform