Re: Prevents Events From Interrupting Events
- From: Peter Duniho <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Mon, 20 Aug 2007 11:39:17 -0700
jehugaleahsa@xxxxxxxxx wrote:
I got away from another thread by having events manage the download
process. In other words, I have an event set the next file to
download.
That doesn't answer the question. Just having an event or an event handler does not in and of itself avoid the use of a thread. In fact, in many scenarios events are implemented as a way for a thread to easily execute code that needs to execute when certain things happen in that thread.
I am starting to think, however, that I should create another thread
to handle the downloading. This will help reduce some of the
complexity of overlapping event handlers and booleans.
Adding another thread will also add to the complexity of your design. Since your design already has a deadlock condition as it is, I would be surprised if you can fix that basic design issue by adding a new thread and you could easily just make it harder to fix.
Thanks for your response. By the way . . . is it possible for the same
thread to deadlock itself with the help of events? or is the lock
keyword ignored when it is the same thread?
Thread synchronization isn't ignored when it occurs multiple times in the same thread. However, it is nested without any problem or potential for a thread deadlocking itself. So within the same thread, you can use the lock() statement or similar synchronization mechanism multiple times without any trouble.
For the best answers, you should put together a concise-but-complete example of code that reliably reproduces the problem you're having and post that here. Without that, it's very difficult to comment intelligently on the specifics of your design and how you would best avoid the deadlock issue.
Pete
.
- References:
- Prevents Events From Interrupting Events
- From: jehugaleahsa@xxxxxxxxx
- Re: Prevents Events From Interrupting Events
- From: Peter Duniho
- Re: Prevents Events From Interrupting Events
- From: jehugaleahsa@xxxxxxxxx
- Prevents Events From Interrupting Events
- Prev by Date: Line on graphic object is not drawn from origin i've choosen.
- Next by Date: Re: Windows Service - Dies during sleep
- Previous by thread: Re: Prevents Events From Interrupting Events
- Next by thread: Bitmap.FromFile generates Out Of Memory with some icons!!
- Index(es):
Relevant Pages
|
Loading